{"record":{"id":"c11e72a4ae233f80","repo":"nats-io/nats-server","slug":"unable-to-write-keys-file-to-q-v","errorCode":null,"errorMessage":"unable to write keys file to %q: %v","messagePattern":"unable to write keys file to %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/tpm/js_ek_tpm_windows.go","lineNumber":108,"sourceCode":"base64.StdEncoding.Encode(tpmKeys.PrivateKey, privateBlob)\nbase64.StdEncoding.Encode(tpmKeys.PublicKey, publicBlob)\n// Convert to JSON\nkeysJSON, err := json.Marshal(tpmKeys)\nif err != nil {\n\treturn fmt.Errorf(\"unable to marshal keys to JSON: %v\", err)\n}\n// Write the JSON to a file\nif err := os.WriteFile(filename, keysJSON, 0640); err != nil {\n\treturn fmt.Errorf(\"unable to write keys file to %q: %v\", filename, err)\n}\nreturn nil","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/tpm/js_ek_tpm_windows.go#L90-L126","documentation":"After successfully JSON-encoding the sealed TPM blobs, writeTPMKeysToFile could not write the keys file at the given path via os.WriteFile. This fires when the target directory was removed between creation and write, the filesystem is full or read-only, permission bits deny writing, or the path is invalid — leaving the server without a persisted JetStream encryption key.","triggerScenarios":"Thrown at server/tpm/js_ek_tpm_windows.go:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and that the filesystem containing the key file is writable","Verify the server process has write permission on the key directory (created 0750)","Confirm the configured jsKeyFile path is valid and its parent directory exists","Fix the underlying OS error (wrapped as %v) and restart so the key is created and sealed again"],"exampleFix":null,"handlingStrategy":"retry","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-08T15:18:49.778Z"}