{"record":{"id":"35014813dd2728d8","repo":"benbjohnson/litestream","slug":"cannot-specify-url-bucket-for-oss-replica","errorCode":null,"errorMessage":"cannot specify url & bucket for oss replica","messagePattern":"cannot specify url & bucket for oss replica","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":1994,"sourceCode":"\t\tclient.MaxReconnects = *c.MaxReconnects\n\t}\n\tif c.ReconnectWait != nil {\n\t\tclient.ReconnectWait = *c.ReconnectWait\n\t}\n\tif c.Timeout != nil {\n\t\tclient.Timeout = *c.Timeout\n\t}\n\n\treturn client, nil\n}\n\n// newOSSReplicaClientFromConfig returns a new instance of oss.ReplicaClient built from config.\nfunc newOSSReplicaClientFromConfig(c *ReplicaConfig, _ *litestream.Replica) (_ *oss.ReplicaClient, err error) {\n\t// Ensure URL & constituent parts are not both specified.\n\tif c.URL != \"\" && c.Path != \"\" {\n\t\treturn nil, fmt.Errorf(\"cannot specify url & path for oss replica\")\n\t} else if c.URL != \"\" && c.Bucket != \"\" {\n\t\treturn nil, fmt.Errorf(\"cannot specify url & bucket for oss replica\")\n\t}\n\n\tbucket, configPath := c.Bucket, c.Path\n\tregion, endpoint := c.Region, c.Endpoint\n\n\t// Apply settings from URL, if specified.\n\tif c.URL != \"\" {\n\t\t_, host, upath, err := litestream.ParseReplicaURL(c.URL)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar (\n\t\t\tubucket string\n\t\t\turegion string\n\t\t)\n\n\t\tubucket, uregion, _ = oss.ParseHost(host)","sourceCodeStart":1976,"sourceCodeEnd":2012,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L1976-L2012","documentation":"Validation guard in newOSSReplicaClientFromConfig that rejects an Alibaba OSS replica config specifying both the full replica 'url' and the 'bucket' field, since the URL host already encodes bucket and region. Fires when ReplicaConfig.URL and ReplicaConfig.Bucket are both non-empty.","triggerScenarios":"A replica config containing both `url: oss://mybucket/prefix` and `bucket: mybucket`.","commonSituations":"Porting an S3-style config (which allows both forms) to OSS; adding a URL while leaving the old `bucket` key in place.","solutions":["Remove the `bucket` field and keep only `url`.","Or drop `url` and configure `bucket` (+ `path`, `region`, `endpoint`) as separate fields.","Search the replica block for leftover S3-era keys and delete them."],"exampleFix":"# before\nreplicas:\n  - url: oss://mybucket/backups\n    bucket: mybucket\n# after\nreplicas:\n  - url: oss://mybucket/backups","handlingStrategy":"validation","validationCode":"// Reject ambiguous OSS config before invoking litestream\nif cfg.URL != \"\" && cfg.Bucket != \"\" {\n    return fmt.Errorf(\"oss replica: choose either url or bucket, not both\")\n}","typeGuard":null,"tryCatchPattern":"if err := runReplicate(); err != nil {\n    if strings.Contains(err.Error(), \"cannot specify url & bucket\") {\n        // remove bucket or url from config\n    }\n}","preventionTips":["If you specify url, never also list bucket/path/region unless required.","Keep a canonical OSS config template per style and copy from it."],"tags":["oss","config","ambiguous"],"backgroundTag":"conflicting-config-options","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}