{"record":{"id":"3d1b8f93129b48bb","repo":"ipfs/kubo","slug":"bad-gateway-address-w","errorCode":null,"errorMessage":"bad gateway address: %w","messagePattern":"bad gateway address: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/fsrepo/migrations/migrations.go","lineNumber":187,"sourceCode":"\tvar fetchers []Fetcher\n\tfor _, src := range downloadSources {\n\t\tsrc := strings.TrimSpace(src)\n\t\tswitch src {\n\t\tcase \"HTTPS\", \"https\", \"HTTP\", \"http\":\n\t\t\t// Expand the alias into the full ordered list of trustless\n\t\t\t// community-provided gateways so migration survives a\n\t\t\t// single-gateway outage.\n\t\t\tfor _, gw := range defaultMigrationGateways {\n\t\t\t\tfetchers = append(fetchers, NewHttpFetcher(distPath, gw, httpUserAgent, 0))\n\t\t\t}\n\t\tcase \"IPFS\", \"ipfs\":\n\t\t\treturn nil, errors.New(\"IPFS downloads are not supported for legacy migrations (repo versions <16). Please use only HTTPS in Migration.DownloadSources\")\n\t\tcase \"\":\n\t\t\t// Ignore empty string\n\t\tdefault:\n\t\t\tu, err := url.Parse(src)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"bad gateway address: %w\", err)\n\t\t\t}\n\t\t\tswitch u.Scheme {\n\t\t\tcase \"\":\n\t\t\t\tu.Scheme = \"https\"\n\t\t\tcase \"https\", \"http\":\n\t\t\tdefault:\n\t\t\t\treturn nil, errors.New(\"bad gateway address: url scheme must be http or https\")\n\t\t\t}\n\t\t\tfetchers = append(fetchers, NewHttpFetcher(distPath, u.String(), httpUserAgent, 0))\n\t\t}\n\t}\n\n\tswitch len(fetchers) {\n\tcase 0:\n\t\treturn nil, errors.New(\"no sources specified\")\n\tcase 1:\n\t\treturn fetchers[0], nil\n\t}","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/repo/fsrepo/migrations/migrations.go#L169-L205","documentation":"For custom DownloadSources entries in GetMigrationFetcher, each non-keyword value is parsed as a URL of a gateway/mirror. This error wraps a url.Parse failure for such an entry, meaning the configured source string is not a valid URL.","triggerScenarios":"Migration.DownloadSources containing a custom gateway string that is not URL-parseable (spaces, stray characters, malformed like \"http//host\").","commonSituations":"Hand-editing DownloadSources JSON with a typo; pasting a URL with quotes or whitespace embedded; forgetting the \"//\" after the scheme.","solutions":["Fix the malformed URL in Migration.DownloadSources so it parses (e.g. \"https://ipfs.io\").","Validate each entry with url.Parse before writing it to config.","Use `ipfs config --json Migration.DownloadSources '[...]'` to write well-formed JSON values instead of manual edits."],"exampleFix":"// before\n\"DownloadSources\": [\"https:/gateway.example.com\"]\n// after\n\"DownloadSources\": [\"https://gateway.example.com\"]","handlingStrategy":"validation","validationCode":"for _, src := range sources {\n    if _, err := url.Parse(src); err != nil {\n        return fmt.Errorf(\"bad DownloadSources entry %q: %w\", src, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"bad gateway address\") {\n        // fix or drop the offending DownloadSources entry\n    }\n}","preventionTips":["Test each custom gateway URL with url.Parse before saving config","Write sources via `ipfs config --json` to avoid quoting errors","Trim spaces and quotes from pasted URLs"],"tags":["migrations","url-parsing","config-validation","go"],"backgroundTag":"bad-gateway-address","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}