{"record":{"id":"8160fe01719024d2","repo":"nats-io/nats-server","slug":"key-to-merge-is-not-a-valid-public-account-key","errorCode":null,"errorMessage":"key to merge is not a valid public account key","messagePattern":"key to merge is not a valid public account key","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/dirstore.go","lineNumber":333,"sourceCode":"\treturn err\n}\n\n// Merge takes the JWTs from package and adds them to the store\n// Merge is destructive in the sense that it doesn't check if the JWT\n// is newer or anything like that.\nfunc (store *DirJWTStore) Merge(pack string) error {\n\tnewJWTs := strings.Split(pack, \"\\n\")\n\tfor _, line := range newJWTs {\n\t\tif line == _EMPTY_ { // ignore blank lines\n\t\t\tcontinue\n\t\t}\n\t\tsplit := strings.Split(line, \"|\")\n\t\tif len(split) != 2 {\n\t\t\treturn fmt.Errorf(\"line in package didn't contain 2 entries: %q\", line)\n\t\t}\n\t\tpubKey := split[0]\n\t\tif !nkeys.IsValidPublicAccountKey(pubKey) {\n\t\t\treturn fmt.Errorf(\"key to merge is not a valid public account key\")\n\t\t}\n\t\tif err := store.saveIfNewer(pubKey, split[1]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (store *DirJWTStore) Reload() error {\n\tstore.Lock()\n\texp := store.expiration\n\tif exp == nil || store.readonly {\n\t\tstore.Unlock()\n\t\treturn nil\n\t}\n\tidx := exp.idx\n\tchanged := store.changed\n\tisCache := store.expiration.evictOnLimit","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/dirstore.go#L315-L351","documentation":"DirJWTStore.Merge: the pubKey part of a package line failed nkeys.IsValidPublicAccountKey, meaning it is not a well-formed account public key (must be an 'A'-prefixed 56-char nkey).","triggerScenarios":"Thrown at server/dirstore.go:333 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the account's real public nkey as the first field","Re-export the package with correct keys","Check for copy/paste corruption of the key"],"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-08T15:18:49.778Z"}