{"record":{"id":"29ce552939631096","repo":"benbjohnson/litestream","slug":"cannot-specify-url-host-for-sftp-replica","errorCode":null,"errorMessage":"cannot specify url & host for sftp replica","messagePattern":"cannot specify url & host for sftp replica","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":1807,"sourceCode":"\t\t\tclient.Path = strings.TrimPrefix(path.Clean(u.Path), \"/\")\n\t\t}\n\t}\n\n\t// Ensure required settings are set.\n\tif client.Bucket == \"\" {\n\t\treturn nil, fmt.Errorf(\"bucket required for abs replica\")\n\t}\n\n\treturn client, nil\n}\n\n// newSFTPReplicaClientFromConfig returns a new instance of sftp.ReplicaClient built from config.\nfunc newSFTPReplicaClientFromConfig(c *ReplicaConfig, _ *litestream.Replica) (_ *sftp.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 sftp replica\")\n\t} else if c.URL != \"\" && c.Host != \"\" {\n\t\treturn nil, fmt.Errorf(\"cannot specify url & host for sftp replica\")\n\t}\n\n\thost, user, password, path := c.Host, c.User, c.Password, c.Path\n\n\t// Apply settings from URL, if specified.\n\tif c.URL != \"\" {\n\t\tu, err := url.Parse(c.URL)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Only apply URL parts to field that have not been overridden.\n\t\tif host == \"\" {\n\t\t\thost = u.Host\n\t\t}\n\t\tif user == \"\" && u.User != nil {\n\t\t\tuser = u.User.Username()\n\t\t}","sourceCodeStart":1789,"sourceCodeEnd":1825,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L1789-L1825","documentation":"newSFTPReplicaClientFromConfig rejects configs that set both 'url' and the individual 'host' field for an sftp replica. Host is a constituent of the URL, so specifying both is ambiguous and the constructor fails fast at startup.","triggerScenarios":"An sftp replica config where c.URL is non-empty AND c.Host is non-empty, e.g. url: 'sftp://backup.example.com/db' plus host: 'backup.example.com'.","commonSituations":"Copy-pasting a URL into an existing config that already had host: set; automation that fills all fields from a template regardless of which style is used.","solutions":["Remove the 'host' field and let the URL provide the host","Or drop 'url' and keep host/user/password/path fields individually","If host must differ from the URL's, use separate fields only (no url)"],"exampleFix":"# before\n- type: sftp\n  url: sftp://user@host/db\n  host: other.example.com\n# after\n- type: sftp\n  url: sftp://user@host/db","handlingStrategy":"validation","validationCode":"if rep.Type == \"sftp\" && rep.URL != \"\" && rep.Host != \"\" {\n    return fmt.Errorf(\"sftp replica %s: url and host are mutually exclusive\", rep.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a url, delete leftover host/user/path keys","Audit generated/templated configs for both styles present","Put host in the URL (sftp://user@host/path) instead of a separate key"],"tags":["config","sftp","litestream","validation"],"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-14T05:17:10.506Z"}