{"record":{"id":"b11da11f9268d5ee","repo":"multica-ai/multica","slug":"resolve-profile-q-w","errorCode":null,"errorMessage":"resolve profile %q: %w","messagePattern":"resolve profile %q: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_daemon.go","lineNumber":499,"sourceCode":"// a flat \"stopped\" — indistinguishable from a daemon that is genuinely not\n// running, even while the correctly-named daemon serves happily on another\n// port (#6694). Failing loudly with the known names turns that dead end into a\n// one-glance fix.\n//\n// The default profile is never validated: it owns ~/.multica directly, has no\n// entry under profiles/, and is always legitimate.\n//\n// Callers must invoke this AFTER their daemon-managed-task guard\n// (requireHumanLocalCommand, or daemonStatusHealthPort for status). Listing the\n// profiles root inside a task would disclose the Owner's profile names, which\n// those guards exist to prevent.\nfunc requireKnownProfile(profile string) error {\n\tif profile == \"\" {\n\t\treturn nil\n\t}\n\texists, err := profileExists(profile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"resolve profile %q: %w\", profile, err)\n\t}\n\tif exists {\n\t\treturn nil\n\t}\n\t// Only now is the listing worth its disk walk, and only now can it be\n\t// wrong in a way the user sees.\n\tnames, err := knownProfiles()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"list profiles: %w\", err)\n\t}\n\treturn &unknownProfileError{Profile: profile, Known: names}\n}\n\n// --- daemon start ---\n\n// daemonExecutable resolves the binary to spawn as the background daemon\n// child. Tests override it: spawning the resolved executable there would fork\n// the test binary itself, which ignores the daemon args and re-runs the suite.","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_daemon.go#L481-L517","documentation":"requireKnownProfile first checks whether the given daemon profile exists (profileExists). If that check itself errors — typically a filesystem failure reading the profiles/ directory — the failure is wrapped as 'resolve profile %q: %w'. This is not 'unknown profile' (that path returns unknownProfileError separately after listing); it means the existence probe broke.","triggerScenarios":"Profiles directory unreadable (permissions changed, disk error), path type conflict (a file where a directory is expected), or OS-level I/O errors while running a daemon command with --profile <name>.","commonSituations":"Profiles root moved or its permissions tightened after setup; running under a different user (sudo vs normal) that cannot read the profiles dir; partially deleted state from a crashed uninstall.","solutions":["Inspect the wrapped error for the OS cause (permission denied, no such file, etc.).","Fix permissions/ownership on the profiles directory (e.g. chmod/chown the daemon config root).","Run the same command without --profile to confirm the base config path is healthy, then re-create the profile."],"exampleFix":"# before: running as wrong user\nsudo multica daemon status --profile work\n# after\nmultica daemon status --profile work","handlingStrategy":"validation","validationCode":"# verify the profiles dir is readable before daemon commands\nPROFILES_ROOT=\"${XDG_CONFIG_HOME:-$HOME/.config}/multica/profiles\"\ntest -r \"$PROFILES_ROOT\" && test -x \"$PROFILES_ROOT\" \\\n  || { echo \"profiles dir unreadable: $PROFILES_ROOT\" >&2; exit 2; }\nmultica daemon status --profile work","typeGuard":null,"tryCatchPattern":"err := runDaemonCmd()\nif err != nil && strings.Contains(err.Error(), \"resolve profile\") {\n    // filesystem-level: inspect inner error with errors.Unwrap for EACCES/ENOENT\n    // do NOT treat as 'unknown profile' — that has its own unknownProfileError type\n}","preventionTips":["Run daemon commands as the user that owns the config/profiles directory.","After moving or restoring a home dir, re-check ownership of the profiles root before starting the daemon."],"tags":["cli","daemon","filesystem","permissions","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}