{"record":{"id":"e02197df03e3d313","repo":"benbjohnson/litestream","slug":"invalid-scheme-for-nats-replica-s","errorCode":null,"errorMessage":"invalid scheme for NATS replica: %s","messagePattern":"invalid scheme for NATS replica: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":1922,"sourceCode":"\tclient.URL = webdavURL\n\tclient.Username = username\n\tclient.Password = password\n\tclient.Path = path\n\n\treturn client, nil\n}\n\n// newNATSReplicaClientFromConfig returns a new instance of nats.ReplicaClient built from config.\nfunc newNATSReplicaClientFromConfig(c *ReplicaConfig, _ *litestream.Replica) (_ *nats.ReplicaClient, err error) {\n\t// Parse URL if provided to extract bucket name and server URL\n\tvar url, bucket string\n\tif c.URL != \"\" {\n\t\tscheme, host, bucketPath, err := litestream.ParseReplicaURL(c.URL)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid NATS URL: %w\", err)\n\t\t}\n\t\tif scheme != \"nats\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid scheme for NATS replica: %s\", scheme)\n\t\t}\n\n\t\t// Reconstruct URL without bucket path\n\t\tif host != \"\" {\n\t\t\turl = fmt.Sprintf(\"nats://%s\", host)\n\t\t}\n\n\t\t// Extract bucket name from path\n\t\tif bucketPath != \"\" {\n\t\t\tbucket = strings.Trim(bucketPath, \"/\")\n\t\t}\n\t}\n\n\t// Use bucket from config if not extracted from URL\n\tif bucket == \"\" {\n\t\tbucket = c.Bucket\n\t}\n","sourceCodeStart":1904,"sourceCodeEnd":1940,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L1904-L1940","documentation":"After successfully parsing c.URL, newNATSReplicaClientFromConfig verifies the scheme equals 'nats'. Any other scheme (s3, abs, file, sftp, ...) means the URL describes a different backend, so this error reports the offending scheme verbatim.","triggerScenarios":"A nats replica whose 'url' uses a non-nats scheme, e.g. url: 's3://bucket/path' inside a type: nats block, or a typo like 'nats2://host/bucket'.","commonSituations":"Copy-pasting a replica URL from another backend's config into a nats replica block; swapping replica 'type' without updating the url scheme.","solutions":["Change the URL scheme to 'nats://', e.g. 'nats://nats.example.com:4222/mybucket'","Or change the replica type to match the scheme you actually intended","Search the config for other replica blocks and ensure url schemes align with each block's type"],"exampleFix":"# before\n- type: nats\n  url: s3://mybucket/db\n# after\n- type: nats\n  url: nats://nats.example.com:4222/mybucket","handlingStrategy":"validation","validationCode":"if rep.Type == \"nats\" && rep.URL != \"\" {\n    if scheme, _, _, err := litestream.ParseReplicaURL(rep.URL); err == nil && scheme != \"nats\" {\n        return fmt.Errorf(\"nats replica %s: expected nats:// scheme, got %s\", rep.Name, scheme)\n    }\n}","typeGuard":"func isNATSScheme(raw string) bool {\n    scheme, _, _, err := litestream.ParseReplicaURL(raw)\n    return err == nil && scheme == \"nats\"\n}","tryCatchPattern":null,"preventionTips":["Keep replica type and url scheme consistent per block","Never copy urls between replica blocks of different types","Grep configs for url schemes that don't match their block type"],"tags":["config","nats","url","litestream"],"backgroundTag":"invalid-enum-value","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"}