{"record":{"id":"cb28b5a7545f609c","repo":"router-for-me/CLIProxyAPI","slug":"xai-token-storage-create-directory-w","errorCode":null,"errorMessage":"xai token storage: create directory: %w","messagePattern":"xai token storage: create directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/token.go","lineNumber":46,"sourceCode":"\tRedirectURI   string `json:\"redirect_uri,omitempty\"`\n\tTokenEndpoint string `json:\"token_endpoint,omitempty\"`\n\tAuthKind      string `json:\"auth_kind,omitempty\"`\n\n\tMetadata map[string]any `json:\"-\"`\n}\n\n// SetMetadata allows the token store to merge status fields before saving.\nfunc (ts *TokenStorage) SetMetadata(meta map[string]any) {\n\tts.Metadata = meta\n}\n\n// SaveTokenToFile writes xAI credentials to a JSON auth file.\nfunc (ts *TokenStorage) SaveTokenToFile(authFilePath string) error {\n\tmisc.LogSavingCredentials(authFilePath)\n\tts.Type = \"xai\"\n\tts.AuthKind = \"oauth\"\n\tif errMkdirAll := os.MkdirAll(filepath.Dir(authFilePath), 0o700); errMkdirAll != nil {\n\t\treturn fmt.Errorf(\"xai token storage: create directory: %w\", errMkdirAll)\n\t}\n\n\tdata, errMerge := misc.MergeMetadata(ts, ts.Metadata)\n\tif errMerge != nil {\n\t\treturn fmt.Errorf(\"xai token storage: merge metadata: %w\", errMerge)\n\t}\n\n\tfile, err := os.Create(authFilePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"xai token storage: create token file: %w\", err)\n\t}\n\tdefer func() {\n\t\tif errClose := file.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"xai token storage: close token file error: %v\", errClose)\n\t\t}\n\t}()\n\n\tencoder := json.NewEncoder(file)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/token.go#L28-L64","documentation":"Error \"xai token storage: create directory: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/token.go:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the auth directory path is writable and the parent directories exist.","Check the wrapped error for permission or filesystem failures and fix directory permissions."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}