{"record":{"id":"fc701f56d16ff3b2","repo":"multica-ai/multica","slug":"failed-to-save-config-w","errorCode":null,"errorMessage":"failed to save config: %w","messagePattern":"failed to save config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_auth.go","lineNumber":356,"sourceCode":"\tpatClient := cli.NewAPIClient(serverURL, \"\", patResp.Token)\n\tvar me struct {\n\t\tName  string `json:\"name\"`\n\t\tEmail string `json:\"email\"`\n\t}\n\tif err := patClient.GetJSON(ctx, \"/api/me\", &me); err != nil {\n\t\treturn cli.WithUserMessage(\"Sign-in did not complete: the server did not accept the new credential. Run `multica login` again.\", err)\n\t}\n\n\t// Save to config. Reset workspace data on every login — the user or\n\t// server may have changed, so stale workspaces must not persist.\n\tprofile := resolveProfile(cmd)\n\tcfg, _ := cli.LoadCLIConfigForProfile(profile)\n\tcfg.WorkspaceID = \"\"\n\tcfg.Token = patResp.Token\n\tcfg.ServerURL = serverURL\n\tcfg.AppURL = appURL\n\tif err := cli.SaveCLIConfigForProfile(cfg, profile); err != nil {\n\t\treturn fmt.Errorf(\"failed to save config: %w\", err)\n\t}\n\n\tfmt.Fprintf(os.Stderr, \"Authenticated as %s (%s)\\nToken saved to config.\\n\", me.Name, me.Email)\n\treturn nil\n}\n\nfunc runningInSSHSession() bool {\n\tfor _, key := range []string{\"SSH_CONNECTION\", \"SSH_CLIENT\", \"SSH_TTY\"} {\n\t\tif strings.TrimSpace(os.Getenv(key)) != \"\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc callbackHostFlagValue(cmd *cobra.Command) string {\n\tfor c := cmd; c != nil; c = c.Parent() {\n\t\tif value := nonEmptyFlagValue(c.Flags(), callbackHostFlag); value != \"\" {","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_auth.go#L338-L374","documentation":"After a successful browser login the CLI writes the updated profile config (new PAT token, server/app URLs, workspace reset) via SaveCLIConfigForProfile. This error wraps any failure persisting that file, meaning login succeeded server-side but the credential was not saved locally.","triggerScenarios":"Config directory not writable (permissions, read-only home); disk full; XDG/config path resolving to a file instead of a directory; SELinux/AppArmor denying writes to the config path.","commonSituations":"Running the CLI as a different user than the one who owns ~/.config; shared/locked-down machines; containers with read-only home; home quota exceeded.","solutions":["Check and fix permissions on the profile config directory (e.g. ~/.config/multica or the XDG path) — ensure it is writable by the current user","Free disk space if the volume is full","If a file exists where the config directory should be, remove/rename it","After fixing, rerun `multica login` (the server-side PAT may already exist; re-login is harmless)"],"exampleFix":"# diagnose and fix\nls -la ~/.config/multica 2>/dev/null || echo 'missing'\nmkdir -p ~/.config/multica && chmod u+w ~/.config/multica\nmultica login","handlingStrategy":"validation","validationCode":"# verify the config dir is writable before login\ncfgdir=\"${XDG_CONFIG_HOME:-$HOME/.config}/multica\"\nmkdir -p \"$cfgdir\" && [ -w \"$cfgdir\" ] || { echo \"config dir not writable: $cfgdir\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision and permission the config directory during environment setup, before first login","Check disk space before login on space-constrained VMs"],"tags":["cli","auth","filesystem","configuration","login"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}