{"record":{"id":"fb5c080810849b32","repo":"nats-io/nats-server","slug":"stream-import-prefix-can-not-contain-wildcard-toke","errorCode":null,"errorMessage":"stream import prefix can not contain wildcard tokens","messagePattern":"stream import prefix can not contain wildcard tokens","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/errors.go","lineNumber":141,"sourceCode":"\tErrAccountValidation = errors.New(\"account validation failed\")\n\n\t// ErrAccountExpired is returned when an account has expired.\n\tErrAccountExpired = errors.New(\"account expired\")\n\n\t// ErrNoAccountResolver is returned when we attempt an update but do not have an account resolver.\n\tErrNoAccountResolver = errors.New(\"account resolver missing\")\n\n\t// ErrAccountResolverUpdateTooSoon is returned when we attempt an update too soon to last request.\n\tErrAccountResolverUpdateTooSoon = errors.New(\"account resolver update too soon\")\n\n\t// ErrAccountResolverSameClaims is returned when same claims have been fetched.\n\tErrAccountResolverSameClaims = errors.New(\"account resolver no new claims\")\n\n\t// ErrStreamImportAuthorization is returned when a stream import is not authorized.\n\tErrStreamImportAuthorization = errors.New(\"stream import not authorized\")\n\n\t// ErrStreamImportBadPrefix is returned when a stream import prefix contains wildcards.\n\tErrStreamImportBadPrefix = errors.New(\"stream import prefix can not contain wildcard tokens\")\n\n\t// ErrStreamImportDuplicate is returned when a stream import is a duplicate of one that already exists.\n\tErrStreamImportDuplicate = errors.New(\"stream import already exists\")\n\n\t// ErrServiceImportAuthorization is returned when a service import is not authorized.\n\tErrServiceImportAuthorization = errors.New(\"service import not authorized\")\n\n\t// ErrImportFormsCycle is returned when an import would form a cycle.\n\tErrImportFormsCycle = errors.New(\"import forms a cycle\")\n\n\t// ErrCycleSearchDepth is returned when we have exceeded our maximum search depth..\n\tErrCycleSearchDepth = errors.New(\"search cycle depth exhausted\")\n\n\t// ErrClientOrRouteConnectedToGatewayPort represents an error condition when\n\t// a client or route attempted to connect to the Gateway port.\n\tErrClientOrRouteConnectedToGatewayPort = errors.New(\"attempted to connect to gateway port\")\n\n\t// ErrWrongGateway represents an error condition when a server receives a connect","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/errors.go#L123-L159","documentation":"ErrStreamImportBadPrefix is returned when a stream import prefix contains wildcard tokens. Prefix-based imports prepend the prefix to the publish subject, so the prefix must be a literal subject; wildcards (*, >) would produce invalid subjects and are rejected.","triggerScenarios":"Calling AddStreamImport with a non-empty prefix argument where subjectIsLiteral(prefix) is false — e.g. AddStreamImport(from, \"to\", \"foo.*\") or \"pre>\" (accounts.go:2720).","commonSituations":"Trying to fan out an import across multiple subjects with \"*\" or \">\" in the prefix; assuming wildcard prefixes behave like wildcards in subscriptions; copy-pasting subscription subjects into the prefix argument of config or code.","solutions":["Use a literal (token-by-token, no * or >) prefix string in AddStreamImport","If multiple subjects are needed, add one import per subject or map a concrete prefix and subscribe under prefix.<subject>","Validate/escape user-supplied prefixes with subjectIsLiteral before calling the API","Restructure exports so a single literal prefix can cover the needed subjects"],"exampleFix":"// before\nacc.AddStreamImport(fooAcc, \"to\", \"foo.*.bar\") // wildcard in prefix\n// after\nacc.AddStreamImport(fooAcc, \"to\", \"foo.one.bar\") // literal prefix","handlingStrategy":"validation","validationCode":"if prefix != \"\" && !subjectIsLiteral(prefix) { return fmt.Errorf(\"import prefix %q must not contain wildcards\", prefix) }","typeGuard":"func validImportPrefix(prefix string) bool { return prefix == _EMPTY_ || subjectIsLiteral(prefix) }","tryCatchPattern":"if err := acc.AddStreamImport(fromAcc, subject, prefix); err != nil {\n\tif errors.Is(err, ErrStreamImportBadPrefix) { /* replace wildcard prefix with a literal subject */ }\n}","preventionTips":["Use only literal subject tokens as import prefixes","Never reuse subscription wildcards (*, >) as prefixes","Validate prefixes with subjectIsLiteral in config loaders"],"tags":["nats","server","subject","stream-import"],"backgroundTag":"invalid-subject-wildcard","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}