{"record":{"id":"6689b37a0d13b3d4","repo":"charmbracelet/crush","slug":"could-not-create-request-w-6689b3","errorCode":null,"errorMessage":"could not create request: %w","messagePattern":"could not create request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/hyper.go","lineNumber":151,"sourceCode":"\t\tif refreshErr := r.refreshToken(ctx); refreshErr != nil {\n\t\t\tslog.Warn(\"Failed to refresh Hyper token\", \"error\", refreshErr)\n\t\t\treturn result, err\n\t\t}\n\t\tresult, err = r.doGet(ctx, \"\")\n\t}\n\treturn result, err\n}\n\nfunc (r realHyperClient) doGet(ctx context.Context, etag string) (catwalk.Provider, error) {\n\tvar result catwalk.Provider\n\treq, err := http.NewRequestWithContext(\n\t\tctx,\n\t\thttp.MethodGet,\n\t\tr.baseURL+\"/api/v1/provider\",\n\t\tnil,\n\t)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"could not create request: %w\", err)\n\t}\n\txetag.Request(req, etag)\n\tif apiKey := r.resolveKey(); apiKey != \"\" {\n\t\treq.Header.Set(\"Authorization\", \"Bearer \"+apiKey)\n\t}\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"failed to make request: %w\", err)\n\t}\n\tdefer resp.Body.Close() //nolint:errcheck\n\n\tif resp.StatusCode == http.StatusNotModified {\n\t\treturn result, catwalk.ErrNotModified\n\t}\n\n\tif resp.StatusCode == http.StatusUnauthorized {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/config/hyper.go#L133-L169","documentation":"Wraps an error from http.NewRequestWithContext inside the Hyper provider client's doGet (used by Get to fetch /api/v1/provider). The method, URL composition, and body are all static, so a failure here means the composed URL (r.baseURL + path) is not a valid URL. The etag and auth headers are set only after this point.","triggerScenarios":"Calling hyper client Get when r.baseURL is empty, malformed (bad scheme, control characters, spaces), or was misconfigured so the concatenation baseURL+\"/api/v1/provider\" fails to parse.","commonSituations":"Hyper base URL left empty because configuration did not resolve; a custom override with a typo like \"hyper:/api\" or trailing whitespace; env expansion producing a garbage value for the base URL.","solutions":["Verify the Hyper base URL configuration (default https://api.hyperbolic.xyz) is set and well-formed.","If the base URL comes from an env variable or config field, print it and correct it.","Re-copy the Hyper API endpoint from their docs, ensuring https:// scheme and no trailing spaces.","Check that no custom override in crushrc is clobbering the default with an invalid value."],"exampleFix":"// before\nbaseURL := \"\" // unset -> invalid composed URL\n// after\nbaseURL := \"https://api.hyperbolic.xyz\"\n// composed: https://api.hyperbolic.xyz/api/v1/provider","handlingStrategy":"validation","validationCode":"u, err := url.Parse(hyperBaseURL + \"/api/v1/provider\")\nif err != nil || u.Host == \"\" {\n    return fmt.Errorf(\"hyper baseURL %q produces invalid request URL\", hyperBaseURL)\n}","typeGuard":"func validHyperBase(raw string) bool {\n    u, err := url.Parse(strings.TrimSpace(raw) + \"/api/v1/provider\")\n    return err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\") && u.Host != \"\"\n}","tryCatchPattern":"result, err := client.Get(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"could not create request\") {\n        log.Fatalf(\"check hyper base URL configuration: %v\", err)\n    }\n    return err\n}","preventionTips":["Set the Hyper base URL explicitly in config instead of relying on empty defaults.","Run url.Parse on any custom base URL at config load time.","Trim whitespace from URLs read from env or config files."],"tags":["http","url","hyper","config"],"backgroundTag":"invalid-url","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}