{"record":{"id":"efc45a35bb8b23b3","repo":"router-for-me/CLIProxyAPI","slug":"auth-path-is-empty-efc45a","errorCode":null,"errorMessage":"auth path is empty","messagePattern":"auth path is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pluginhost/auth_callbacks.go","lineNumber":307,"sourceCode":"\t\t\tdst = abs\n\t\t}\n\t}\n\tauth, errBuild := h.buildAuthFromFileData(dst, data)\n\tif errBuild != nil {\n\t\treturn \"\", errBuild\n\t}\n\tif errWrite := os.WriteFile(dst, data, 0o600); errWrite != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to write auth file: %w\", errWrite)\n\t}\n\tif errUpsert := h.upsertAuthRecord(ctx, auth); errUpsert != nil {\n\t\treturn \"\", errUpsert\n\t}\n\treturn dst, nil\n}\n\nfunc (h *Host) buildAuthFromFileData(path string, data []byte) (*coreauth.Auth, error) {\n\tif strings.TrimSpace(path) == \"\" {\n\t\treturn nil, fmt.Errorf(\"auth path is empty\")\n\t}\n\tif data == nil {\n\t\tvar errRead error\n\t\tdata, errRead = os.ReadFile(path)\n\t\tif errRead != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read auth file: %w\", errRead)\n\t\t}\n\t}\n\tmetadata := make(map[string]any)\n\tif errUnmarshal := json.Unmarshal(data, &metadata); errUnmarshal != nil {\n\t\treturn nil, fmt.Errorf(\"invalid auth file: %w\", errUnmarshal)\n\t}\n\tprovider, _ := metadata[\"type\"].(string)\n\tif strings.TrimSpace(provider) == \"\" {\n\t\tprovider = \"unknown\"\n\t}\n\tlabel := provider\n\tif email, ok := metadata[\"email\"].(string); ok && strings.TrimSpace(email) != \"\" {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/pluginhost/auth_callbacks.go#L289-L325","documentation":"Thrown by Host.buildAuthFromFileData when the path argument trims to empty. The builder needs a concrete file path to derive the auth identity (authIDForPath) and to optionally read data; an empty path is a programming-error-level input.","triggerScenarios":"Caller passes an empty/unset path string, typically when a save flow computed the destination from an empty auth-dir or an upstream field was never populated.","commonSituations":"Internal misuse of the build API; a code path where resolvedAuthDir returned \"\" and Join produced an empty result; refactoring that dropped the path argument.","solutions":["Ensure the destination path is built from a non-empty directory plus base name before calling build","Guard upstream: reject empty paths at the entry point (saveAuthFile already checks auth dir separately)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if strings.TrimSpace(path) == \"\" {\n    return errors.New(\"empty auth path\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build paths as filepath.Join(dir, filepath.Base(name)) from validated non-empty parts","Assert non-empty path in unit tests covering the save flow"],"tags":["go","pluginhost","auth","validation","internal-api"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}