nats-io/nats-server · error

error setting up pack request handling: %v

Error message

error setting up pack request handling: %v

What it means

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.

Source

Thrown at server/accounts.go:4606

	if _, err := s.sysSubscribeQ(accPackReqSubj, "responder", func(_ *subscription, _ *client, _ *Account, _, reply string, theirHash []byte) {
		if reply == _EMPTY_ {
			return
		}
		ourHash := dr.DirJWTStore.Hash()
		if bytes.Equal(theirHash, ourHash[:]) {
			s.sendInternalMsgLocked(reply, _EMPTY_, nil, []byte{})
			s.Debugf("DirResolver - Pack request matches hash %x", ourHash[:])
		} else if err := dr.DirJWTStore.PackWalk(1, func(partialPackMsg string) {
			s.sendInternalMsgLocked(reply, _EMPTY_, nil, []byte(partialPackMsg))
		}); err != nil {
			// let them timeout
			s.Errorf("DirResolver - Pack request error: %v", err)
		} else {
			s.Debugf("DirResolver - Pack request hash %x - finished responding with hash %x", theirHash, ourHash)
			s.sendInternalMsgLocked(reply, _EMPTY_, nil, []byte{})
		}
	}); err != nil {
		return fmt.Errorf("error setting up pack request handling: %v", err)
	}
	// respond to list requests with one message containing all account ids
	if _, err := s.sysSubscribe(accListReqSubj, func(_ *subscription, _ *client, _ *Account, _, reply string, _ []byte) {
		handleListRequest(dr.DirJWTStore, s, reply)
	}); err != nil {
		return fmt.Errorf("error setting up list request handling: %v", err)
	}
	if _, err := s.sysSubscribe(accDeleteReqSubj, func(_ *subscription, c *client, _ *Account, _, reply string, msg []byte) {
		// As this is a raw message, we need to extract payload and only decode claims from it,
		// in case request is sent with headers.
		_, msg = c.msgParts(msg)
		handleDeleteRequest(dr.DirJWTStore, s, msg, reply)
	}); err != nil {
		return fmt.Errorf("error setting up delete request handling: %v", err)
	}
	// embed pack responses into store
	if _, err := s.sysSubscribe(packRespIb, func(_ *subscription, _ *client, _ *Account, _, _ string, msg []byte) {
		hash := dr.DirJWTStore.Hash()

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Configure a valid system account (system_account in config) so sysSubscribe can attach internal subscriptions.
  2. Check the wrapped inner error (%v) to identify why the subscription failed.
  3. Ensure the resolver is started only after the server's eventing/system client is initialized.
  4. Verify operator/JWT resolver settings (dir path, interval) are valid in server options.

Example fix

// before: server config missing system account
accounts: {}
// after
system_account: SYS
accounts: { SYS: { users: [{ user: sys, password: sys }] } }
Defensive patterns

Strategy: validation

Validate before calling

// before starting a dir resolver
if srv.Opts.SystemAccount == "" {
    return fmt.Errorf("dir resolver requires a configured system account")
}
if err := srv.eventingReady(); err != nil {
    return err
}

Try / catch

if err := dr.Start(); err != nil {
    if strings.HasPrefix(err.Error(), "error setting up pack request handling") {
        log.Fatalf("resolver setup failed (system account/eventing): %v", err)
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/022e6158985af03d. Report an issue: GitHub.