{"record":{"id":"221c683f8461162b","repo":"router-for-me/CLIProxyAPI","slug":"xai-token-storage-write-token-file-w","errorCode":null,"errorMessage":"xai token storage: write token file: %w","messagePattern":"xai token storage: write token file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/xai/token.go","lineNumber":67,"sourceCode":"\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)\n\tencoder.SetIndent(\"\", \"  \")\n\tif err = encoder.Encode(data); err != nil {\n\t\treturn fmt.Errorf(\"xai token storage: write token file: %w\", err)\n\t}\n\treturn nil\n}\n\n// CredentialFileName returns the filename used for xAI credentials.\nfunc CredentialFileName(email, subject string) string {\n\temail = sanitizeFileSegment(email)\n\tif email != \"\" {\n\t\treturn fmt.Sprintf(\"xai-%s.json\", email)\n\t}\n\tsubject = sanitizeFileSegment(subject)\n\tif subject != \"\" {\n\t\treturn fmt.Sprintf(\"xai-%s.json\", subject)\n\t}\n\treturn fmt.Sprintf(\"xai-%d.json\", time.Now().UnixMilli())\n}\n\nfunc sanitizeFileSegment(value string) string {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/xai/token.go#L49-L85","documentation":"Error \"xai token storage: write token file: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/xai/token.go:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check available disk space and write permissions on the auth directory.","Retry after resolving the wrapped I/O error."],"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-15T17:31:12.345Z"}