{"record":{"id":"4f81242ccaa9fcbc","repo":"nats-io/nats-server","slug":"stream-description-is-too-long-maximum-allowed-is","errorCode":null,"errorMessage":"stream description is too long, maximum allowed is %d","messagePattern":"stream description is too long, maximum allowed is (.+?)","errorType":"error_code","errorClass":"JSStreamInvalidConfigError","httpStatus":null,"severity":"error","filePath":"server/stream.go","lineNumber":1880,"sourceCode":"\t}\n\treturn s.checkStreamCfgLocked(config, acc, pedantic)\n}\n\n// jetStream lock (read or write) should be held, if JetStream is enabled.\nfunc (s *Server) checkStreamCfgLocked(config *StreamConfig, acc *Account, pedantic bool) (StreamConfig, *ApiError) {\n\tlim := &s.getOpts().JetStreamLimits\n\n\tif config == nil {\n\t\treturn StreamConfig{}, NewJSStreamInvalidConfigError(fmt.Errorf(\"stream configuration invalid\"))\n\t}\n\tif !isValidAssetName(config.Name) {\n\t\treturn StreamConfig{}, NewJSStreamInvalidConfigError(fmt.Errorf(\"stream name is required and can not contain '.', '*', '>', '\\\\', '/'\"))\n\t}\n\tif len(config.Name) > JSMaxNameLen {\n\t\treturn StreamConfig{}, NewJSStreamInvalidConfigError(fmt.Errorf(\"stream name is too long, maximum allowed is %d\", JSMaxNameLen))\n\t}\n\tif len(config.Description) > JSMaxDescriptionLen {\n\t\treturn StreamConfig{}, NewJSStreamInvalidConfigError(fmt.Errorf(\"stream description is too long, maximum allowed is %d\", JSMaxDescriptionLen))\n\t}\n\n\tvar metadataLen int\n\tfor k, v := range config.Metadata {\n\t\tmetadataLen += len(k) + len(v)\n\t}\n\tif metadataLen > JSMaxMetadataLen {\n\t\treturn StreamConfig{}, NewJSStreamInvalidConfigError(fmt.Errorf(\"stream metadata exceeds maximum size of %d bytes\", JSMaxMetadataLen))\n\t}\n\n\tcfg := *config\n\n\tif _, err := cfg.Retention.MarshalJSON(); err != nil {\n\t\treturn cfg, NewJSStreamInvalidConfigError(fmt.Errorf(\"invalid retention\"))\n\t}\n\tif _, err := cfg.Discard.MarshalJSON(); err != nil {\n\t\treturn cfg, NewJSStreamInvalidConfigError(fmt.Errorf(\"invalid discard policy\"))\n\t}","sourceCodeStart":1862,"sourceCodeEnd":1898,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream.go#L1862-L1898","documentation":"checkStreamCfgLocked: the stream's human-readable Description exceeds JSMaxDescriptionLen bytes. Purely a config-size guard on the optional description field; the maximum allowed length is printed so the operator can truncate accordingly.","triggerScenarios":"Creating or updating a stream with StreamConfig.Description longer than 4096 bytes, e.g. embedding documentation, JSON blobs, or auto-generated text into the description field.","commonSituations":"Storing schema definitions or owner/contact info in the description; scripts that dump a file's contents into the description; templates that interpolate large values.","solutions":["Shorten the description to <=4096 bytes.","Move large documentation to external storage and reference a URL in the description.","Use Metadata for machine-readable key/value data with its own (larger) budget.","Add a client-side length check before calling AddStream/Update."],"exampleFix":"// before\ncfg := jetstream.StreamConfig{Name: \"ORDERS\", Description: strings.Repeat(\"x\", 5000)}\n// after\ndesc := strings.Repeat(\"x\", 5000)\ncfg := jetstream.StreamConfig{Name: \"ORDERS\", Description: desc[:4000]}","handlingStrategy":"validation","validationCode":"func validDescription(d string) error {\n  if len(d) > 4096 {\n    return fmt.Errorf(\"description too long: %d > 4096\", len(d))\n  }\n  return nil\n}","typeGuard":"func descFits(d string) bool { return len(d) <= 4096 }","tryCatchPattern":null,"preventionTips":["Truncate descriptions to a sane length at config load time.","Don't embed documents, schemas, or dump output into Description.","Use Metadata for structured data within its 128 KiB budget.","Byte-count (len) descriptions containing non-ASCII text."],"tags":["jetstream","stream-config","length-limit","description"],"backgroundTag":"stream-description-too-long","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}