{"record":{"id":"022e6158985af03d","repo":"nats-io/nats-server","slug":"error-setting-up-pack-request-handling-v","errorCode":null,"errorMessage":"error setting up pack request handling: %v","messagePattern":"error setting up pack request handling: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/accounts.go","lineNumber":4606,"sourceCode":"\tif _, err := s.sysSubscribeQ(accPackReqSubj, \"responder\", func(_ *subscription, _ *client, _ *Account, _, reply string, theirHash []byte) {\n\t\tif reply == _EMPTY_ {\n\t\t\treturn\n\t\t}\n\t\tourHash := dr.DirJWTStore.Hash()\n\t\tif bytes.Equal(theirHash, ourHash[:]) {\n\t\t\ts.sendInternalMsgLocked(reply, _EMPTY_, nil, []byte{})\n\t\t\ts.Debugf(\"DirResolver - Pack request matches hash %x\", ourHash[:])\n\t\t} else if err := dr.DirJWTStore.PackWalk(1, func(partialPackMsg string) {\n\t\t\ts.sendInternalMsgLocked(reply, _EMPTY_, nil, []byte(partialPackMsg))\n\t\t}); err != nil {\n\t\t\t// let them timeout\n\t\t\ts.Errorf(\"DirResolver - Pack request error: %v\", err)\n\t\t} else {\n\t\t\ts.Debugf(\"DirResolver - Pack request hash %x - finished responding with hash %x\", theirHash, ourHash)\n\t\t\ts.sendInternalMsgLocked(reply, _EMPTY_, nil, []byte{})\n\t\t}\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"error setting up pack request handling: %v\", err)\n\t}\n\t// respond to list requests with one message containing all account ids\n\tif _, err := s.sysSubscribe(accListReqSubj, func(_ *subscription, _ *client, _ *Account, _, reply string, _ []byte) {\n\t\thandleListRequest(dr.DirJWTStore, s, reply)\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"error setting up list request handling: %v\", err)\n\t}\n\tif _, err := s.sysSubscribe(accDeleteReqSubj, func(_ *subscription, c *client, _ *Account, _, reply string, msg []byte) {\n\t\t// As this is a raw message, we need to extract payload and only decode claims from it,\n\t\t// in case request is sent with headers.\n\t\t_, msg = c.msgParts(msg)\n\t\thandleDeleteRequest(dr.DirJWTStore, s, msg, reply)\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"error setting up delete request handling: %v\", err)\n\t}\n\t// embed pack responses into store\n\tif _, err := s.sysSubscribe(packRespIb, func(_ *subscription, _ *client, _ *Account, _, _ string, msg []byte) {\n\t\thash := dr.DirJWTStore.Hash()","sourceCodeStart":4588,"sourceCodeEnd":4624,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/accounts.go#L4588-L4624","documentation":"Returned by the DirAccResolver setup when the internal system-level subscription for account 'pack' requests (accPackReqSubj) fails to be established via sysSubscribe. It wraps the underlying subscription error, meaning the resolver's directory-JWT synchronization machinery could not register its handler for pack requests from other servers in the cluster.","triggerScenarios":"Calling Start() on a DirAccResolver (or server startup with a resolver configured via account resolver options) when sysSubscribe(accPackReqSubj, ...) returns an error — typically because the system account or eventing subsystem is not yet initialized/unavailable.","commonSituations":"Server startup with a directory-based account resolver but no system account properly configured; starting a resolver before internal eventing is up; misconfigured accounts in server config.","solutions":["Configure a valid system account (system_account in config) so sysSubscribe can attach internal subscriptions.","Check the wrapped inner error (%v) to identify why the subscription failed.","Ensure the resolver is started only after the server's eventing/system client is initialized.","Verify operator/JWT resolver settings (dir path, interval) are valid in server options."],"exampleFix":"// before: server config missing system account\naccounts: {}\n// after\nsystem_account: SYS\naccounts: { SYS: { users: [{ user: sys, password: sys }] } }","handlingStrategy":"validation","validationCode":"// before starting a dir resolver\nif srv.Opts.SystemAccount == \"\" {\n    return fmt.Errorf(\"dir resolver requires a configured system account\")\n}\nif err := srv.eventingReady(); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := dr.Start(); err != nil {\n    if strings.HasPrefix(err.Error(), \"error setting up pack request handling\") {\n        log.Fatalf(\"resolver setup failed (system account/eventing): %v\", err)\n    }\n}","preventionTips":["Always set system_account in server config when using an account resolver.","Start resolvers only after server eventing is initialized.","Log the wrapped inner error, not just the outer message.","Test resolver startup in CI with the same config as production."],"tags":["nats-server","account-resolver","subscription","system-account"],"backgroundTag":"internal-subscription-setup-failed","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}