{"record":{"id":"84df0acd60e60255","repo":"router-for-me/CLIProxyAPI","slug":"auth-file-not-found","errorCode":null,"errorMessage":"auth file not found","messagePattern":"auth file not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/api/handlers/management/auth_files.go","lineNumber":32,"sourceCode":"\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/router-for-me/CLIProxyAPI/v7/internal/auth/codex\"\n\t\"github.com/router-for-me/CLIProxyAPI/v7/internal/config\"\n\t\"github.com/router-for-me/CLIProxyAPI/v7/internal/credentialweight\"\n\t\"github.com/router-for-me/CLIProxyAPI/v7/internal/registry\"\n\tcoreauth \"github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth\"\n\tlog \"github.com/sirupsen/logrus\"\n\t\"github.com/tidwall/gjson\"\n)\n\nvar lastRefreshKeys = []string{\"last_refresh\", \"lastRefresh\", \"last_refreshed_at\", \"lastRefreshedAt\"}\n\nvar (\n\tcallbackForwardersMu  sync.Mutex\n\tcallbackForwarders    = make(map[int]*callbackForwarder)\n\tauthFileEntryMu       sync.Mutex\n\terrAuthFileMustBeJSON = errors.New(\"auth file must be .json\")\n\terrAuthFileNotFound   = errors.New(\"auth file not found\")\n\terrPluginVirtualAuth  = errors.New(\"plugin virtual auth cannot be modified directly; edit or delete the source auth file\")\n\tnewCodexOAuthService  = func(cfg *config.Config) codexOAuthService { return codex.NewCodexAuth(cfg) }\n)\n\nfunc extractLastRefreshTimestamp(meta map[string]any) (time.Time, bool) {\n\tif len(meta) == 0 {\n\t\treturn time.Time{}, false\n\t}\n\tfor _, key := range lastRefreshKeys {\n\t\tif val, ok := meta[key]; ok {\n\t\t\tif ts, ok1 := parseLastRefreshValue(val); ok1 {\n\t\t\t\treturn ts, true\n\t\t\t}\n\t\t}\n\t}\n\treturn time.Time{}, false\n}\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/handlers/management/auth_files.go#L14-L50","documentation":"Thrown when the plugin host cannot JSON-decode the RPC payload that a plugin sent for the host.model.execute_stream callback. The request bytes must unmarshal into rpcHostModelExecutionRequest; any syntax error, wrong field type, or truncated payload fails here. It always wraps the underlying encoding/json error with %w.","triggerScenarios":"A plugin calls host.model.execute_stream with a malformed JSON body: truncated buffers from the C ABI boundary, string values where numbers are expected, or a request struct serialized by a plugin built against an older/newer rpcHostModelExecutionRequest schema.","commonSituations":"Plugin compiled from a different SDK version whose request struct differs from the host's; bugs in the plugin's RPC serialization; memory corruption in the C bridge producing garbage bytes; manual JSON hand-crafted for testing.","solutions":["Rebuild the plugin against the same SDK/pluginapi version the host binary uses (go.mod module github.com/router-for-me/CLIProxyAPI/v7).","Log the raw request bytes at the RPC boundary to identify which field fails to unmarshal.","Validate in the plugin that the request is serialized with json.Marshal of the generated HostModelExecutionRequest struct, not hand-built JSON.","Check the C buffer handling (length vs NUL termination) if the plugin is not written in Go."],"exampleFix":"// plugin side: marshal the typed struct, never hand-build the payload\nreq := pluginapi.HostModelExecutionRequest{Model: \"gpt-4o\", Stream: true, /* ... */}\nraw, err := json.Marshal(req)\nif err != nil {\n    return err\n}\nresp, err := host.Call(ctx, \"host.model.execute_stream\", raw)","handlingStrategy":"try-catch","validationCode":"// plugin side: marshal the typed struct before sending\nraw, err := json.Marshal(req)\nif err != nil {\n    return fmt.Errorf(\"serialize request: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, err := host.Call(ctx, \"host.model.execute_stream\", raw)\nif err != nil {\n    var syntaxErr *json.SyntaxError\n    if errors.As(err, &syntaxErr) {\n        // request payload malformed on our side: fix serialization, do not retry\n        return fmt.Errorf(\"plugin request schema bug: %w\", err)\n    }\n    return err\n}","preventionTips":["Always json.Marshal the generated pluginapi request structs; never hand-build request JSON.","Build plugin and host from the same SDK version.","Keep RPC request construction in one helper so schema changes are caught at compile time."],"tags":["pluginhost","json","rpc","deserialization"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}