{"record":{"id":"ac9884db74a05a89","repo":"nats-io/nats-server","slug":"sealed-stream","errorCode":null,"errorMessage":"sealed stream","messagePattern":"sealed stream","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/stream.go","lineNumber":3101,"sourceCode":"// Purge will remove all messages from the stream and underlying store based on the request.\nfunc (mset *stream) purge(preq *JSApiStreamPurgeRequest) (purged uint64, err error) {\n\t// Purges mutate message state, so hold the isolation lock like any other\n\t// write so direct get requests don't observe a partially applied purge.\n\tmset.isolateMu.Lock()\n\tdefer mset.isolateMu.Unlock()\n\treturn mset.purgeLocked(preq, true)\n}\n\nfunc (mset *stream) purgeLocked(preq *JSApiStreamPurgeRequest, needLock bool) (purged uint64, err error) {\n\tif needLock {\n\t\tmset.mu.Lock()\n\t\tdefer mset.mu.Unlock()\n\t}\n\tif mset.closed.Load() {\n\t\treturn 0, errStreamClosed\n\t}\n\tif mset.cfg.Sealed {\n\t\treturn 0, errors.New(\"sealed stream\")\n\t}\n\tstore, mlseq := mset.store, mset.lseq\n\n\tif preq != nil {\n\t\tpurged, err = mset.store.PurgeEx(preq.Subject, preq.Sequence, preq.Keep)\n\t} else {\n\t\tpurged, err = mset.store.Purge()\n\t}\n\tif err != nil {\n\t\treturn purged, err\n\t}\n\n\t// Grab our stream state.\n\tvar state StreamState\n\tstore.FastState(&state)\n\tfseq, lseq := state.FirstSeq, state.LastSeq\n\n\t// Check if our last has moved past what our original last sequence was, if so reset.","sourceCodeStart":3083,"sourceCodeEnd":3119,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/stream.go#L3083-L3119","documentation":"A mutating operation (e.g. purge) was attempted on a sealed stream. Sealed streams are immutable by definition, so the request is rejected while holding the stream lock. The stream's sealed state combined with the attempted mutation is the cause.","triggerScenarios":"Thrown at server/stream.go:3101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unseal the stream (if supported) before mutating it","Delete and recreate the stream if data changes are required","Skip purge and message-delete operations on sealed streams"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}