{"record":{"id":"578d0498e6a728a5","repo":"hashicorp/terraform","slug":"failed-to-parse-address-url-s","errorCode":null,"errorMessage":"failed to parse address URL: %s","messagePattern":"failed to parse address URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/http/backend.go","lineNumber":133,"sourceCode":"\tbackendbase.Base\n\n\tclient *httpClient\n}\n\nfunc (b *Backend) Configure(configVal cty.Value) tfdiags.Diagnostics {\n\taddress := backendbase.GetAttrEnvDefaultFallback(\n\t\tconfigVal, \"address\",\n\t\t\"TF_HTTP_ADDRESS\", cty.StringVal(\"\"),\n\t).AsString()\n\tif address == \"\" {\n\t\treturn backendbase.ErrorAsDiagnostics(\n\t\t\tfmt.Errorf(\"address argument is required\"),\n\t\t)\n\t}\n\tupdateURL, err := url.Parse(address)\n\tif err != nil {\n\t\treturn backendbase.ErrorAsDiagnostics(\n\t\t\tfmt.Errorf(\"failed to parse address URL: %s\", err),\n\t\t)\n\t}\n\tif updateURL.Scheme != \"http\" && updateURL.Scheme != \"https\" {\n\t\treturn backendbase.ErrorAsDiagnostics(\n\t\t\tfmt.Errorf(\"address must be HTTP or HTTPS\"),\n\t\t)\n\t}\n\n\tupdateMethod := backendbase.GetAttrEnvDefaultFallback(\n\t\tconfigVal, \"update_method\",\n\t\t\"TF_HTTP_UPDATE_METHOD\", cty.StringVal(\"POST\"),\n\t).AsString()\n\n\tvar lockURL *url.URL\n\tif v := backendbase.GetAttrEnvDefault(configVal, \"lock_address\", \"TF_HTTP_LOCK_ADDRESS\"); !v.IsNull() {\n\t\tvar err error\n\t\tlockURL, err = url.Parse(v.AsString())\n\t\tif err != nil {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/http/backend.go#L115-L151","documentation":"Thrown by the HTTP backend when url.Parse(address) returns an error. The address string was non-empty but malformed enough that Go's net/url rejects it (e.g., control characters, missing scheme with invalid characters, or an unparseable URL).","triggerScenarios":"url.Parse(address) returns a non-nil error — typically a stray space or control character in the URL, a missing scheme combined with other invalid syntax, or a value that is not a URL at all.","commonSituations":"Variable interpolation leaves a leading space; address was built by string concatenation that introduced a newline; user pasted a path without scheme; trailing slash issues are not this error (those parse fine).","solutions":["Inspect the address for stray whitespace, newlines, or control characters and remove them.","Ensure the address includes a scheme (http:// or https://).","Print the resolved address before terraform runs to catch interpolation bugs.","Use trimprefix/trimsuffix/trimspace on the variable producing the URL."],"exampleFix":"// before\naddress = \" ${var.state_url}\"   # leading space\n// after\naddress = trimspace(var.state_url)","handlingStrategy":"validation","validationCode":"address := strings.TrimSpace(rawAddress)\nif address == \"\" {\n    return fmt.Errorf(\"address is empty\")\n}\nu, err := url.Parse(address)\nif err != nil {\n    return fmt.Errorf(\"address is not a valid URL: %w\", err)\n}\nif u.Scheme != \"http\" && u.Scheme != \"https\" {\n    return fmt.Errorf(\"address must use http or https\")\n}","typeGuard":"func isValidHTTPURL(s string) bool {\n    u, err := url.Parse(strings.TrimSpace(s))\n    return err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\")\n}","tryCatchPattern":null,"preventionTips":["Trim whitespace from URL-producing variables.","Always include the scheme in the address.","Add a CI lint that url.Parses the address and asserts http/https scheme."],"tags":["http","backend","configuration","url","validation"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}