{"record":{"id":"d786c6d327b6bb0e","repo":"nats-io/nats-server","slug":"stream-configuration-for-republish-from-s-to","errorCode":null,"errorMessage":"stream configuration for republish from '%s' to '%s': %w","messagePattern":"stream configuration for republish from '(.+?)' to '(.+?)': %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream.go","lineNumber":2862,"sourceCode":"\t\t\tmset.subscribeToMirrorDirect()\n\t\t} else {\n\t\t\tmset.unsubscribeToMirrorDirect()\n\t\t}\n\t}\n\n\t// Check for changes to RePublish.\n\tif cfg.RePublish != nil {\n\t\t// Empty same as all.\n\t\tif cfg.RePublish.Source == _EMPTY_ {\n\t\t\tcfg.RePublish.Source = fwcs\n\t\t}\n\t\tif cfg.RePublish.Destination == _EMPTY_ {\n\t\t\tcfg.RePublish.Destination = fwcs\n\t\t}\n\t\ttr, err := NewSubjectTransform(cfg.RePublish.Source, cfg.RePublish.Destination)\n\t\tif err != nil {\n\t\t\tmset.mu.Unlock()\n\t\t\treturn fmt.Errorf(\"stream configuration for republish from '%s' to '%s': %w\", cfg.RePublish.Source, cfg.RePublish.Destination, err)\n\t\t}\n\t\t// Assign our transform for republishing.\n\t\tmset.tr = tr\n\t} else {\n\t\tmset.tr = nil\n\t}\n\n\t// Check for changes to subject transform\n\tif ocfg.SubjectTransform == nil && cfg.SubjectTransform != nil {\n\t\ttr, err := NewSubjectTransform(cfg.SubjectTransform.Source, cfg.SubjectTransform.Destination)\n\t\tif err != nil {\n\t\t\tmset.mu.Unlock()\n\t\t\treturn fmt.Errorf(\"stream configuration for subject transform from '%s' to '%s': %w\", cfg.SubjectTransform.Source, cfg.SubjectTransform.Destination, err)\n\t\t}\n\t\tmset.itr = tr\n\t} else if ocfg.SubjectTransform != nil && cfg.SubjectTransform != nil &&\n\t\t(ocfg.SubjectTransform.Source != cfg.SubjectTransform.Source || ocfg.SubjectTransform.Destination != cfg.SubjectTransform.Destination) {\n\t\ttr, err := NewSubjectTransform(cfg.SubjectTransform.Source, cfg.SubjectTransform.Destination)","sourceCodeStart":2844,"sourceCodeEnd":2880,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream.go#L2844-L2880","documentation":"During stream setup/update, the RePublish configuration is compiled into a SubjectTransform via NewSubjectTransform; a failure is wrapped as \"stream configuration for republish from '%s' to '%s'\". It means the RePublish.Source or RePublish.Destination subject in the stream config is not a valid transformable subject.","triggerScenarios":"UpdateStream/CreateStream with StreamConfig.RePublish whose Source/Destination cannot be compiled, e.g. RePublish.Source with invalid wildcards or a Destination incompatible with the source's token count.","commonSituations":"Destination with different number of wildcard tokens than Source (e.g. Source 'foo.*' -> Destination 'bar.*.*'), invalid subject characters, or empty/whitespace source.","solutions":["Make the RePublish.Destination have the same number of tokens/wildcards as the Source.","Validate subjects (syntax and wildcard placement) before submitting the config.","Remove RePublish or set it to nil if republishing is not required."],"exampleFix":"// before\nRePublish: &RePublish{Source: \"foo.*\", Destination: \"bar.*.*\"}\n// after\nRePublish: &RePublish{Source: \"foo.*\", Destination: \"bar.*\"}","handlingStrategy":"validation","validationCode":"if rp := cfg.RePublish; rp != nil {\n    if err := validTransformPair(rp.Source, rp.Destination); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"republish from\") { /* fix RePublish.Source/Destination */ }","preventionTips":["Use the same number of wildcard tokens in Source and Destination.","Test transforms on a scratch stream before production updates."],"tags":["jetstream","republish","subject-transform","validation"],"backgroundTag":"invalid-subject-transform","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}