{"record":{"id":"85d7d1191b089ae0","repo":"router-for-me/CLIProxyAPI","slug":"create-request-w","errorCode":null,"errorMessage":"create request: %w","messagePattern":"create request: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/antigravity/auth.go","lineNumber":241,"sourceCode":"\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 {\n\t\t\tlog.Errorf(\"antigravity loadCodeAssist: close body error: %v\", errClose)\n\t\t}\n\t}()\n\n\tbodyBytes, errRead := io.ReadAll(resp.Body)\n\tif errRead != nil {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/antigravity/auth.go#L223-L259","documentation":"Returned by AntigravityAuth.FetchProjectID when http.NewRequestWithContext rejects the POST target for the loadCodeAssist call. The URL is built from the constants APIEndpoint (https://cloudcode-pa.googleapis.com) and APIVersion (v1internal), so parsing fails only if those constants were changed to a malformed URL, or if the passed ctx is nil (NewRequestWithContext panics/errors on nil URL parse results). It is a construction-time guard, not a network error.","triggerScenarios":"Calling FetchProjectID(ctx, token) where ctx is nil, or after overriding internal/auth/antigravity/constants.go APIEndpoint/APIVersion with a string that url.Parse rejects (bad scheme, control characters).","commonSituations":"Forking the proxy to point cloudcode-pa.googleapis.com at a mock or corporate gateway and typo-ing the URL (e.g. missing scheme, embedded space); passing a nil context from a hand-rolled caller instead of context.Background().","solutions":["Check the %w cause: if it mentions 'missing protocol scheme' or 'invalid control character', fix the APIEndpoint/APIVersion constants or the URL-building format string","Ensure the caller passes a non-nil context (context.Background() at minimum)","Rebuild and retry; no network state is involved"],"exampleFix":"// before\nAPIEndpoint = \"cloudcode-pa.googleapis.com\" // no scheme: create request fails\n\n// after\nAPIEndpoint = \"https://cloudcode-pa.googleapis.com\"","handlingStrategy":"validation","validationCode":"if _, errParse := url.Parse(fmt.Sprintf(\"%s/%s:loadCodeAssist\", antigravity.APIEndpoint, antigravity.APIVersion)); errParse != nil || ctx == nil {\n    return fmt.Errorf(\"invalid loadCodeAssist request parameters\")\n}","typeGuard":null,"tryCatchPattern":"projectID, err := auth.FetchProjectID(ctx, token)\nif err != nil {\n    var urlErr *url.Error\n    if errors.As(err, &urlErr) && strings.Contains(urlErr.Err.Error(), \"parse\") {\n        log.Errorf(\"endpoint constant misconfigured: %v\", err)\n    }\n    return err\n}","preventionTips":["Never pass a nil context; default to context.Background()","Validate overridden endpoint constants with url.Parse in a unit test"],"tags":["antigravity","http","url","configuration"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}