{"record":{"id":"bfad53adec723dc3","repo":"hashicorp/nomad","slug":"unknown-check-s-s","errorCode":null,"errorMessage":"unknown check: %s/%s","messagePattern":"unknown check: (.+?)/(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/consul/catalog_testing.go","lineNumber":400,"sourceCode":"\treturn nil\n}\n\n// UpdateTTLOpts implements AgentAPI\nfunc (c *MockAgent) UpdateTTLOpts(id string, output string, status string, q *api.QueryOptions) error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tc.hits++\n\tnamespace := getNamespace(q)\n\n\tchecks, nsExists := c.checks[namespace]\n\tif !nsExists {\n\t\treturn fmt.Errorf(\"unknown checks namespace: %q\", namespace)\n\t}\n\n\tcheck, checkExists := checks[id]\n\tif !checkExists {\n\t\treturn fmt.Errorf(\"unknown check: %s/%s\", namespace, id)\n\t}\n\n\t// Flip initial status to passing\n\t// todo(shoenig) why not just set to the given status?\n\tcheck.Status = \"passing\"\n\tc.checkTTLs[namespace][id]++\n\n\treturn nil\n}\n\n// a convenience method for looking up a registered service by name\nfunc (c *MockAgent) lookupService(namespace, name string) []*api.AgentServiceRegistration {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tvar services []*api.AgentServiceRegistration\n\tfor _, service := range c.services[namespace] {\n\t\tif service.Name == name {","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/consul/catalog_testing.go#L382-L418","documentation":"UpdateTTLOpts in the Consul test helper (catalog_testing.go) updates the status of a known TTL check in a fake Consul agent. It throws 'unknown check: <namespace>/<id>' when the check ID is not present in the fake's check map for that namespace, meaning the test is trying to pass a TTL for a check that was never registered (or was registered under a different namespace).","triggerScenarios":"Calling UpdateTTLOpts(namespace, checkID, ...) on the testing Consul agent where the check was never added via registration, or the check exists in a different namespace, or the ID spelling/case differs.","commonSituations":"Unit tests simulating task/service health updates: the test registers a service but forgets the check, uses the wrong namespace after namespace support was added, or asserts TTL state for a deregistered check.","solutions":["Verify the check was registered before calling UpdateTTLOpts and that the ID matches exactly (case-sensitive).","Pass the correct namespace that the check was registered under (with Consul namespaces enabled, check IDs are scoped per namespace).","Register the check (or seed it in the fake agent's check map) before updating its TTL."],"exampleFix":"// before\nagent.UpdateTTLOpts(\"default\", \"web-check\", api.HealthPassing)\n// after\nagent.RegisterCheck(\"default\", \"web-check\", ...) // ensure it exists\nagent.UpdateTTLOpts(\"default\", \"web-check\", api.HealthPassing)","handlingStrategy":"validation","validationCode":"if checks, ok := agent.Checks()[namespace]; !ok {\n  return fmt.Errorf(\"namespace %q has no checks\", namespace)\n} else if _, ok := checks[id]; !ok {\n  return fmt.Errorf(\"check %q not registered in %q\", id, namespace)\n}","typeGuard":"func checkExists(agent *TestAgent, namespace, id string) bool {\n  checks := agent.Consul().Agent().Checks()\n  _, ok := checks[id]\n  return ok\n}","tryCatchPattern":null,"preventionTips":["Register the check before attempting TTL updates in tests.","Use constants for namespace and check IDs to avoid typos.","Assert registration state before state-mutating calls."],"tags":["consul","testing","ttl-check","nomad"],"backgroundTag":"unknown-consul-check","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"}