{"record":{"id":"c3ca750d05f8e3a9","repo":"ipfs/kubo","slug":"q-could-not-be-parsed-s","errorCode":null,"errorMessage":"%q could not be parsed: %s","messagePattern":"%q could not be parsed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go","lineNumber":277,"sourceCode":"\tf.addrInfo = peer.AddrInfo{\n\t\tID:    node.Identity,\n\t\tAddrs: addrs,\n\t}\n\n\tf.ipfs = ipfs\n\tf.ipfsStopFunc = stopFunc\n\n\treturn nil\n}\n\nfunc parsePath(fetchPath string) (path.Path, error) {\n\tif ipfsPath, err := path.NewPath(fetchPath); err == nil {\n\t\treturn ipfsPath, nil\n\t}\n\n\tu, err := url.Parse(fetchPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%q could not be parsed: %s\", fetchPath, err)\n\t}\n\n\tswitch proto := u.Scheme; proto {\n\tcase \"ipfs\", \"ipld\", \"ipns\":\n\t\treturn path.NewPath(gopath.Join(\"/\", proto, u.Host, u.Path))\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%q is not an IPFS path\", fetchPath)\n\t}\n}\n\nfunc readIpfsConfig(repoRoot *string, userConfigFile string) (bootstrap []string, peers []peer.AddrInfo) {\n\tif repoRoot == nil {\n\t\treturn\n\t}\n\n\tcfgPath, err := config.Filename(*repoRoot, userConfigFile)\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go#L259-L295","documentation":"parsePath in the migrations ipfsfetcher tries to interpret a fetch target as a native IPFS path (via path.NewPath); if that fails it falls back to url.Parse. This error is returned when the string cannot be parsed as a URL at all, meaning the fetchPath is malformed (e.g. contains invalid characters, spaces, or a fundamentally broken URI).","triggerScenarios":"Calling Fetch (or indirectly RunMigration using an IPFS-capable fetcher) with a fetchPath string that is neither a valid IPFS path nor a parseable URL, e.g. \"://bad\" or a string with control characters.","commonSituations":"Typing a migration download source or CID reference by hand with typos or stray characters; copying a URL with surrounding whitespace or quotes; programmatically constructing a fetch string with an unescaped character.","solutions":["Print and inspect the exact fetchPath string; fix or escape invalid URL characters.","Trim whitespace/quotes from the configured Migration.DownloadSources or CID string before use.","Use url.Parse on the string locally to confirm it parses before passing it to the fetcher."],"exampleFix":"// before\nfetcher.Fetch(\"://QmHash\")\n// after\nfetcher.Fetch(\"https://ipfs.io/ipfs/QmHash\")","handlingStrategy":"validation","validationCode":"if _, err := url.Parse(fetchPath); err != nil {\n    return fmt.Errorf(\"invalid fetch path %q: %w\", fetchPath, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var urlErr *url.Error\n    if errors.As(err, &urlErr) { /* bad fetchPath */ }\n}","preventionTips":["Trim whitespace and quotes from all configured download strings","Validate URLs with url.Parse before persisting them to config"],"tags":["migrations","url-parsing","go"],"backgroundTag":"url-parse-failed","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"}