nats-io/nats-server · error

no export defined for %q

Error message

no export defined for %q

What it means

ServiceExportResponseThreshold looks up a service export by subject and returns this error when no export matches (server/accounts.go:2617). The account has no service export registered for the given subject string.

Source

Thrown at server/accounts.go:2617

	// Redo timer as needed.
	acc.mu.Lock()
	if totalResponses > 0 && se.rtmr != nil {
		se.rtmr.Stop()
		se.rtmr.Reset(se.respThresh)
	} else {
		se.clearResponseThresholdTimer()
	}
	acc.mu.Unlock()
}

// ServiceExportResponseThreshold returns the current threshold.
func (a *Account) ServiceExportResponseThreshold(export string) (time.Duration, error) {
	a.mu.Lock()
	defer a.mu.Unlock()
	se := a.getServiceExport(export)
	if se == nil {
		return 0, fmt.Errorf("no export defined for %q", export)
	}
	return se.respThresh, nil
}

// SetServiceExportResponseThreshold sets the maximum time the system will a response to be delivered
// from a service export responder.
func (a *Account) SetServiceExportResponseThreshold(export string, maxTime time.Duration) error {
	a.mu.Lock()
	if a.isClaimAccount() {
		a.mu.Unlock()
		return fmt.Errorf("claim based accounts can not be updated directly")
	}
	lrt := a.lowestServiceExportResponseTime()
	se := a.getServiceExport(export)
	if se == nil {
		a.mu.Unlock()
		return fmt.Errorf("no export defined for %q", export)
	}

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Register the export with AddServiceExport before querying its threshold.
  2. Verify the exact export subject string on the correct account.
  3. Use accountexports or imports.services inspection to list existing exports.

Example fix

// before
d, err := acc.ServiceExportResponseThreshold("typo.subject")
// after
acc.AddServiceExport("help.request", nil)
d, err := acc.ServiceExportResponseThreshold("help.request")
Defensive patterns

Strategy: validation

Validate before calling

if acc.getServiceExport(subject) == nil {
    return fmt.Errorf("export %s not registered", subject)
}

Try / catch

if d, err := acc.ServiceExportResponseThreshold(subject); err != nil {
    if strings.Contains(err.Error(), "no export defined") {
        // register export or fix subject
    }
}

Prevention

When it happens

Trigger: Calling ServiceExportResponseThreshold with a subject that was never registered via AddServiceExport, or after the export was removed.

Common situations: Typos in the export subject; querying the wrong account; exports removed after config/claim updates.

Related errors


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