{"record":{"id":"96f6286114bce6f2","repo":"nats-io/nats-server","slug":"consumer-name-can-not-contain","errorCode":null,"errorMessage":"consumer name can not contain '.', '*', '>', '\\', '/'","messagePattern":"consumer name can not contain '\\.', '\\*', '>', '\\\\', '/'","errorType":"validation","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"server/consumer.go","lineNumber":739,"sourceCode":"\tif config.AckPolicy == AckFlowControl && !pedantic {\n\t\tconfig.FlowControl = true\n\t\tconfig.Heartbeat = sourceHealthHB\n\t}\n\treturn nil\n}\n\n// Check the consumer config. If we are recovering don't check filter subjects.\nfunc checkConsumerCfg(\n\tconfig *ConsumerConfig,\n\tsrvLim *JSLimitOpts,\n\tcfg *StreamConfig,\n\t_ *Account,\n\taccLim *JetStreamAccountLimits,\n\tisRecovering bool,\n) *ApiError {\n\n\tif config.Name != _EMPTY_ && !isValidAssetName(config.Name) {\n\t\treturn NewJSStreamInvalidConfigError(errors.New(\"consumer name can not contain '.', '*', '>', '\\\\', '/'\"))\n\t}\n\tif config.Durable != _EMPTY_ && !isValidAssetName(config.Durable) {\n\t\treturn NewJSStreamInvalidConfigError(errors.New(\"consumer durable name can not contain '.', '*', '>', '\\\\', '/'\"))\n\t}\n\n\t// Check if replicas is defined but exceeds parent stream.\n\tif config.Replicas > 0 && config.Replicas > cfg.Replicas {\n\t\treturn NewJSConsumerReplicasExceedsStreamError()\n\t}\n\t// Check that it is not negative\n\tif config.Replicas < 0 {\n\t\treturn NewJSReplicasCountCannotBeNegativeError()\n\t}\n\t// If the stream is interest or workqueue retention make sure the replicas\n\t// match that of the stream. This is REQUIRED for now.\n\tif cfg.Retention == InterestPolicy || cfg.Retention == WorkQueuePolicy {\n\t\t// Only error here if not recovering.\n\t\t// We handle recovering in a different spot to allow consumer to come up","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/consumer.go#L721-L757","documentation":"The consumer's Name field failed isValidAssetName, meaning it contains one of the forbidden characters '.', '*', '>', '\\\\' or '/'. JetStream asset names are used directly as NATS subjects/tokens, so these wildcard and path characters are rejected. The server returns this wrapped in a JSStreamInvalidConfigError during consumer config validation.","triggerScenarios":"Any consumer create/update API call (js.AddConsumer, $JS.API.CONSUMER.CREATE.<stream>.<name>) where config.Name is non-empty and contains '.', '*', '>', '\\\\' or '/'.","commonSituations":"Deriving consumer names from user input, file paths, or topic names containing dots/slashes; building names like 'app.consumer.v1' with slashes from URLs; accidentally passing a subject instead of a name.","solutions":["Sanitize the consumer name, replacing '.', '*', '>', '\\\\' and '/' with allowed characters such as '-' or '_'.","Generate a name programmatically (e.g. hash or slug) when the source string may contain reserved characters.","Validate names client-side before calling the API.","If a dotted name is required, leave Name empty and set only Durable (also subject to the same rule) or let the server assign one."],"exampleFix":"// before\ncc := &nats.ConsumerConfig{Name: \"orders/eu.consumer\"}\n// after\ncc := &nats.ConsumerConfig{Name: \"orders-eu-consumer\"}","handlingStrategy":"validation","validationCode":"var invalidAssetNameRe = regexp.MustCompile(`[.*>\\\\/]`)\nfunc validConsumerName(name string) bool {\n\treturn name == \"\" || !invalidAssetNameRe.MatchString(name)\n}\nif !validConsumerName(cc.Name) {\n\treturn fmt.Errorf(\"invalid consumer name %q\", cc.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sanitize any user- or domain-derived strings before using them as consumer names","Never pass NATS subjects or URLs directly as consumer names","Add a shared name-slug helper used by all services creating consumers"],"tags":["jetstream","consumer","naming","config-validation"],"backgroundTag":"invalid-asset-name","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}