{"record":{"id":"af02b43c4f903d6c","repo":"amir20/dozzle","slug":"failed-to-create-request","errorCode":null,"errorMessage":"failed to create request","messagePattern":"failed to create request","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/web/cloud.go","lineNumber":63,"sourceCode":"\ttoken := r.URL.Query().Get(\"token\")\n\tfrom := r.URL.Query().Get(\"from\")\n\tif token == \"\" {\n\t\thttp.Error(w, \"missing token parameter\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tcloudURL := os.Getenv(\"DOLIGENCE_URL\")\n\tif cloudURL == \"\" {\n\t\tcloudURL = \"https://doligence.dozzle.dev\"\n\t}\n\n\texchangeURL := fmt.Sprintf(\"%s/api/exchange-token\", cloudURL)\n\n\tclient := cloudHTTPClient\n\treq, err := http.NewRequestWithContext(r.Context(), http.MethodPost, exchangeURL, nil)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"Failed to create request\")\n\t\thttp.Error(w, \"failed to create request\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\treq.Header.Set(\"User-Agent\", dispatcher.UserAgent)\n\tq := req.URL.Query()\n\tq.Set(\"token\", token)\n\treq.URL.RawQuery = q.Encode()\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"Failed to exchange token\")\n\t\thttp.Error(w, \"failed to exchange token\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))\n\t\tlog.Error().Int(\"status\", resp.StatusCode).Str(\"body\", string(body)).Msg(\"Token exchange failed\")","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/web/cloud.go#L45-L81","documentation":"cloudCallback builds a POST to `{DOLIGENCE_URL}/api/exchange-token` using http.NewRequestWithContext. If request construction fails (essentially only on an unparsable URL), it logs and returns 500 with this message. The cloud URL comes from the DOLIGENCE_URL env var or the hardcoded default.","triggerScenarios":"DOLIGENCE_URL env var set to a value that cannot be parsed as a URL (e.g. contains spaces, invalid characters, or control characters), producing a url.Parse error inside http.NewRequestWithContext.","commonSituations":"Operator sets DOLIGENCE_URL with a trailing space or newline in a compose file; quoting mistakes inject invalid characters; missing scheme plus malformed host producing an unparseable URL.","solutions":["Print/inspect the DOLIGENCE_URL value and remove stray whitespace or control characters.","Set DOLIGENCE_URL to a valid absolute URL such as https://doligence.dozzle.dev.","Unset DOLIGENCE_URL to fall back to the built-in default cloud endpoint."],"exampleFix":"// before\nDOLIGENCE_URL=https://doligence.dozzle.dev /api\n// after\nDOLIGENCE_URL=https://doligence.dozzle.dev","handlingStrategy":"validation","validationCode":"const raw = process.env.DOLIGENCE_URL;\nif (raw && !/^https?:\\/\\/[^\\s]+$/.test(raw.trim())) {\n    throw new Error(`DOLIGENCE_URL is not a valid URL: ${JSON.stringify(raw)}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate DOLIGENCE_URL for stray whitespace/characters before starting dozzle.","Prefer the built-in default unless a custom cloud endpoint is truly required.","Quote env vars carefully in compose files and shell scripts."],"tags":["http","url","cloud"],"backgroundTag":"invalid-url","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}