{"record":{"id":"cddc412ddb306838","repo":"benbjohnson/litestream","slug":"oss-invalid-url-scheme","errorCode":null,"errorMessage":"oss: invalid url scheme","messagePattern":"oss: invalid url scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oss/replica_client.go","lineNumber":631,"sourceCode":"// Item returns the metadata for the current file.\nfunc (itr *fileIterator) Item() *ltx.FileInfo {\n\treturn itr.info\n}\n\n// Err returns any error that occurred during iteration.\nfunc (itr *fileIterator) Err() error {\n\treturn itr.err\n}\n\n// ParseURL parses an OSS URL into its host and path parts.\nfunc ParseURL(s string) (bucket, region, key string, err error) {\n\tu, err := url.Parse(s)\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", err\n\t}\n\n\tif u.Scheme != \"oss\" {\n\t\treturn \"\", \"\", \"\", fmt.Errorf(\"oss: invalid url scheme\")\n\t}\n\n\t// Parse host to extract bucket and region\n\tbucket, region, _ = ParseHost(u.Host)\n\tif bucket == \"\" {\n\t\tbucket = u.Host\n\t}\n\n\tkey = strings.TrimPrefix(u.Path, \"/\")\n\treturn bucket, region, key, nil\n}\n\n// ParseHost parses the host/endpoint for an OSS storage system.\n// Supports formats like:\n//   - bucket.oss-cn-hangzhou.aliyuncs.com\n//   - bucket.oss-cn-hangzhou-internal.aliyuncs.com\n//   - bucket (just bucket name)\nfunc ParseHost(host string) (bucket, region, endpoint string) {","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/oss/replica_client.go#L613-L649","documentation":"Validation guard in the OSS client's ParseURL: the URL must use the 'oss' scheme. Fires when a replica URL with another scheme (e.g. s3:// or https://) is passed to OSS URL parsing, typically from a misconfigured replica URL.","triggerScenarios":"Configuring a replica with a URL whose scheme is not oss://, e.g. 's3://bucket/path', 'https://bucket.oss-cn-hangzhou.aliyuncs.com/path', or a typo like 'os://bucket/path' passed through NewReplicaClientFromURL / config parsing.","commonSituations":"Copy-pasting an S3 replica URL into an OSS replica entry; putting an https endpoint URL where the litestream URL is expected; case/scheme typos in litestream.yml.","solutions":["Use the oss:// scheme: url: \"oss://my-bucket.oss-cn-hangzhou.aliyuncs.com/path\".","If the backend is actually S3 or another provider, use the matching replica type instead of the OSS client.","Fix typos in the scheme ('os', 'OSS:' variants are rejected; scheme comparison is exact).","Check that env expansion hasn't mangled the URL (e.g. unescaped $ in the config value)."],"exampleFix":"// before\nurl: \"https://my-bucket.oss-cn-hangzhou.aliyuncs.com/db/ltx\"\n// after\nurl: \"oss://my-bucket.oss-cn-hangzhou.aliyuncs.com/db/ltx\"","handlingStrategy":"validation","validationCode":"u, _ := url.Parse(replicaURL)\nif u.Scheme != \"oss\" {\n    return fmt.Errorf(\"oss replica URL must use oss:// scheme, got %q\", u.Scheme)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write replica URLs as oss://bucket.endpoint/path.","Don't paste https or s3:// URLs into an OSS replica entry.","Escape $ in config values so env expansion can't corrupt the URL."],"tags":["url","config","oss","validation"],"backgroundTag":"invalid-url","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}