{"record":{"id":"a3e9d362a5884e42","repo":"hashicorp/nomad","slug":"service-registration-not-found","errorCode":null,"errorMessage":"service registration not found","messagePattern":"service registration not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"nomad/state/state_store_service_registration.go","lineNumber":108,"sourceCode":"\tdefer txn.Abort()\n\n\tif err := s.deleteServiceRegistrationByIDTxn(index, txn, namespace, id); err != nil {\n\t\treturn err\n\t}\n\treturn txn.Commit()\n}\n\nfunc (s *StateStore) deleteServiceRegistrationByIDTxn(\n\tindex uint64, txn *txn, namespace, id string) error {\n\n\t// Lookup the service registration by its ID and namespace. This is a\n\t// unique index and therefore there will be a maximum of one entry.\n\texisting, err := txn.First(TableServiceRegistrations, indexID, namespace, id)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"service registration lookup failed: %v\", err)\n\t}\n\tif existing == nil {\n\t\treturn errors.New(\"service registration not found\")\n\t}\n\n\t// Delete the existing entry from the table.\n\tif err := txn.Delete(TableServiceRegistrations, existing); err != nil {\n\t\treturn fmt.Errorf(\"service registration deletion failed: %v\", err)\n\t}\n\n\t// Update the index table to indicate an update has occurred.\n\tif err := txn.Insert(tableIndex, &IndexEntry{TableServiceRegistrations, index}); err != nil {\n\t\treturn fmt.Errorf(\"index update failed: %v\", err)\n\t}\n\treturn nil\n}\n\n// DeleteServiceRegistrationByNodeID deletes all service registrations that\n// belong on a single node. If there are no registrations tied to the nodeID,\n// the call will noop without an error.\nfunc (s *StateStore) DeleteServiceRegistrationByNodeID(","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store_service_registration.go#L90-L126","documentation":"deleteServiceRegistrationByIDTxn deletes a service registration by its (namespace, service ID) pair. The unique-index lookup returning nil produces \"service registration not found\", aborting the delete. Registrations are ephemeral (tied to node heartbeats), so they can vanish without any explicit delete.","triggerScenarios":"ServiceRegistration.Delete RPC (nomad service delete or services delete API) for a namespace+ID that is no longer registered; the service deregistered automatically when its node was garbage-collected; duplicate concurrent deletes.","commonSituations":"Cleanup scripts running after Nomad already GC'd the registration via node expiry; deleting with the wrong namespace (e.g., default vs a dedicated one); typos in the ID argument.","solutions":["List current registrations (nomad service info <service>) to confirm the exact namespace and ID.","Pass the correct -namespace flag matching where the service was registered.","Treat not-found as success in cleanup automation since the target state already holds.","Re-register the service if it should exist and the delete was a mistake."],"exampleFix":"// before\nclient.Services().DeleteByID(ns, serviceID, nil)\n// after: tolerate GC'd registrations\nerr := client.Services().DeleteByID(ns, serviceID, nil)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    return nil // already gone (node GC)\n}","handlingStrategy":"fallback","validationCode":"// confirm the registration still exists\nservices, _, err := client.Services().Get(ns, serviceName, nil)\nif err != nil || len(services) == 0 {\n    return nil // nothing registered / already GC'd\n}","typeGuard":null,"tryCatchPattern":"err := client.Services().DeleteByID(ns, serviceID, nil)\nif err != nil && strings.Contains(err.Error(), \"not found\") {\n    return nil // node GC removed it already\n}","preventionTips":["Remember service registrations are ephemeral (node heartbeat GC) — deletes may race GC.","Always pass the namespace the service was registered in.","Write cleanup jobs to converge, not to assume the registration exists."],"tags":["nomad","service-registration","delete-not-found","state-store"],"backgroundTag":"resource-not-found","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}