{"record":{"id":"e31ebab9d4a00bea","repo":"nats-io/nats-server","slug":"store-is-read-only","errorCode":null,"errorMessage":"store is read-only","messagePattern":"store is read-only","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/dirstore.go","lineNumber":454,"sourceCode":"\t\t\ti := store.expiration.lru.Front().Value.(*jwtItem)\n\t\t\tif err := os.Remove(store.pathForKey(i.publicKey)); err != nil {\n\t\t\t\treturn false, err\n\t\t\t} else {\n\t\t\t\tstore.expiration.unTrack(i.publicKey)\n\t\t\t}\n\t\t}\n\t}\n\tif err := os.WriteFile(path, []byte(theJWT), defaultFilePerms); err != nil {\n\t\treturn false, err\n\t} else if store.expiration != nil {\n\t\tstore.expiration.track(publicKey, newHash, theJWT)\n\t}\n\treturn true, nil\n}\n\nfunc (store *DirJWTStore) delete(publicKey string) error {\n\tif store.readonly {\n\t\treturn fmt.Errorf(\"store is read-only\")\n\t} else if store.deleteType == NoDelete {\n\t\treturn fmt.Errorf(\"store is not set up to for delete\")\n\t}\n\tstore.Lock()\n\tdefer store.Unlock()\n\tname := store.pathForKey(publicKey)\n\tif store.deleteType == RenameDeleted {\n\t\tif err := os.Rename(name, name+\".deleted\"); err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t} else if err := os.Remove(name); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn err","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/dirstore.go#L436-L472","documentation":"DirJWTStore.delete guard: the store was opened in read-only mode (store.readonly), so delete operations are refused to keep the on-disk store untouched.","triggerScenarios":"Thrown at server/dirstore.go:454 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-open the store without the read-only flag","Use a writable directory for stores that need deletes","Perform maintenance on the underlying files out-of-band"],"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"}