{"record":{"id":"9616d47a2192d4a0","repo":"router-for-me/CLIProxyAPI","slug":"marshal-request-body-w","errorCode":null,"errorMessage":"marshal request body: %w","messagePattern":"marshal request body: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/antigravity/auth.go","lineNumber":235,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"antigravity userinfo: decode response: %w\", errDecode)\n\t}\n\temail := strings.TrimSpace(info.Email)\n\tif email == \"\" {\n\t\treturn \"\", fmt.Errorf(\"antigravity userinfo: response missing email\")\n\t}\n\treturn email, nil\n}\n\n// FetchProjectID retrieves the project ID for the authenticated user via loadCodeAssist\nfunc (o *AntigravityAuth) FetchProjectID(ctx context.Context, accessToken string) (string, error) {\n\tuserAgent := o.shortUserAgent()\n\tloadReqBody := map[string]any{\n\t\t\"metadata\": antigravityLoadCodeAssistMetadata(),\n\t}\n\n\trawBody, errMarshal := json.Marshal(loadReqBody)\n\tif errMarshal != nil {\n\t\treturn \"\", fmt.Errorf(\"marshal request body: %w\", errMarshal)\n\t}\n\n\tendpointURL := fmt.Sprintf(\"%s/%s:loadCodeAssist\", APIEndpoint, APIVersion)\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, endpointURL, strings.NewReader(string(rawBody)))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"create request: %w\", err)\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+accessToken)\n\treq.Header.Set(\"Accept\", \"*/*\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", userAgent)\n\n\tresp, errDo := o.httpClient.Do(req)\n\tif errDo != nil {\n\t\treturn \"\", fmt.Errorf(\"execute request: %w\", errDo)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/antigravity/auth.go#L217-L253","documentation":"Returned by AntigravityAuth.FetchProjectID when encoding the loadCodeAssist request body to JSON fails. The payload is a statically built map ({\"metadata\": {\"ideType\": \"ANTIGRAVITY\"}}) containing only string keys and string values, so json.Marshal cannot fail for any realistic input. The error exists only as a defensive guard against programming mistakes (e.g. someone later adding an unmarshalable type such as a channel or func to the map). If you see it, code was modified to put an unsupported type into loadReqBody.","triggerScenarios":"Calling FetchProjectID after the request-body map was changed to contain a value json.Marshal cannot encode (chan, func, complex, cyclic pointer). With the shipped literal map this branch is effectively unreachable.","commonSituations":"Developers extending antigravityLoadCodeAssistMetadata() with non-string fields (timestamps as time.Time are fine, but func values or cyclic structs are not); essentially never seen in production.","solutions":["Inspect antigravityLoadCodeAssistMetadata() and any local additions to loadReqBody for values of type chan, func, complex, or self-referencing structs","Replace unmarshalable values with their string or plain-struct equivalents","Run go test ./internal/auth/antigravity/ to confirm the round trip"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := auth.FetchProjectID(ctx, token); err != nil {\n    var target *json.MarshalerError // not directly reachable; treat as programming bug\n    if errors.As(err, &target) {\n        log.Errorf(\"request payload bug: %v\", err)\n    }\n}","preventionTips":["Keep loadCodeAssist request maps composed only of strings and plain structs","Unit-test the request builder so a bad type fails in CI, not during OAuth"],"tags":["antigravity","json","unreachable","oauth"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}