{"record":{"id":"ebb32eabc11bce20","repo":"nats-io/nats-server","slug":"service-missing","errorCode":null,"errorMessage":"service missing","messagePattern":"service missing","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/errors.go","lineNumber":114,"sourceCode":"\t// ErrConnectedToWrongPort represents an error condition when a connection is attempted\n\t// to the wrong listen port (for instance a LeafNode to a client port, etc...)\n\tErrConnectedToWrongPort = errors.New(\"attempted to connect to wrong port\")\n\n\t// ErrAccountExists is returned when an account is attempted to be registered\n\t// but already exists.\n\tErrAccountExists = errors.New(\"account exists\")\n\n\t// ErrBadAccount represents a malformed or incorrect account.\n\tErrBadAccount = errors.New(\"bad account\")\n\n\t// ErrReservedAccount represents a reserved account that can not be created.\n\tErrReservedAccount = errors.New(\"reserved account\")\n\n\t// ErrMissingAccount is returned when an account does not exist.\n\tErrMissingAccount = errors.New(\"account missing\")\n\n\t// ErrMissingService is returned when an account does not have an exported service.\n\tErrMissingService = errors.New(\"service missing\")\n\n\t// ErrBadServiceType is returned when latency tracking is being applied to non-singleton response types.\n\tErrBadServiceType = errors.New(\"bad service response type\")\n\n\t// ErrBadSampling is returned when the sampling for latency tracking is not 1 >= sample <= 100.\n\tErrBadSampling = errors.New(\"bad sampling percentage, should be 1-100\")\n\n\t// ErrAccountValidation is returned when an account has failed validation.\n\tErrAccountValidation = errors.New(\"account validation failed\")\n\n\t// ErrAccountExpired is returned when an account has expired.\n\tErrAccountExpired = errors.New(\"account expired\")\n\n\t// ErrNoAccountResolver is returned when we attempt an update but do not have an account resolver.\n\tErrNoAccountResolver = errors.New(\"account resolver missing\")\n\n\t// ErrAccountResolverUpdateTooSoon is returned when we attempt an update too soon to last request.\n\tErrAccountResolverUpdateTooSoon = errors.New(\"account resolver update too soon\")","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/errors.go#L96-L132","documentation":"ErrMissingService is returned when an account does not have an exported service with the given name. The library throws it from TrackServiceExportWithSampling when the target service export cannot be found on the account (either the exports map is nil or the service key is absent), so latency tracking cannot be attached to a non-existent service.","triggerScenarios":"Calling Account.TrackServiceExportWithSampling(service, respType, sampling) with a service name that was never added via AddServiceImport / service export setup, or before any service exports exist (exports.services is nil), or after the export was removed.","commonSituations":"Typo in the service subject when enabling latency tracking; calling tracking setup before the service import/export is configured; ordering issues during account configuration at startup; running tracking code against an account that only has stream exports, not service exports.","solutions":["Verify the service export exists on the account before calling TrackServiceExportWithSampling; the service name must exactly match the registered export/import subject","Add or configure the service export first (AddServiceImport / claim-based exports) and then enable latency tracking","Check for typos and subject mismatch between the export registration and the tracking call","Ensure account configuration/claims that define the service are applied before the tracking setup runs"],"exampleFix":"// before\nacc.TrackServiceExportWithSampling(\"trk.service\", \"results\", 100) // service never exported\n// after\nif err := srv.AddServiceImport(acc, \"trk\", \"req.service\"); err != nil { t.Fatal(err) }\nerr := acc.TrackServiceExportWithSampling(\"trk\", \"results\", 100)","handlingStrategy":"validation","validationCode":"if acc == nil { return errors.New(\"account required\") }\n// ensure service exists before tracking\nfound := false\nfor svc := range acc.exports.services { if svc == service { found = true } }\nif !found { return fmt.Errorf(\"service %q not exported on account\", service) }","typeGuard":"func hasServiceExport(acc *Account, service string) bool {\n\tacc.mu.RLock(); defer acc.mu.RUnlock()\n\treturn acc.exports != nil && acc.exports.services != nil && acc.exports.services[service] != nil\n}","tryCatchPattern":"if err := acc.TrackServiceExportWithSampling(svc, resp, 100); err != nil {\n\tif errors.Is(err, ErrMissingService) { /* configure export first or skip tracking */ }\n}","preventionTips":["Register the service export before enabling latency tracking","Match service names/subjects exactly between export and tracking calls","Unit-test account config setup order"],"tags":["nats","server","service-latency","configuration"],"backgroundTag":"missing-service-export","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}