{"record":{"id":"4f2c3df61cda2089","repo":"hashicorp/nomad","slug":"scaling-policy-not-found","errorCode":null,"errorMessage":"scaling policy not found","messagePattern":"scaling policy not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"nomad/state/state_store.go","lineNumber":7210,"sourceCode":"\t}\n\n\treturn err\n}\n\n// DeleteScalingPoliciesTxn is used to delete a set of scaling policies by ID.\nfunc (s *StateStore) DeleteScalingPoliciesTxn(index uint64, ids []string, txn *txn) error {\n\tif len(ids) == 0 {\n\t\treturn nil\n\t}\n\n\tfor _, id := range ids {\n\t\t// Lookup the scaling policy\n\t\texisting, err := txn.First(\"scaling_policy\", \"id\", id)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"scaling policy lookup failed: %v\", err)\n\t\t}\n\t\tif existing == nil {\n\t\t\treturn fmt.Errorf(\"scaling policy not found\")\n\t\t}\n\n\t\t// Delete the scaling policy\n\t\tif err := txn.Delete(\"scaling_policy\", existing); err != nil {\n\t\t\treturn fmt.Errorf(\"scaling policy delete failed: %v\", err)\n\t\t}\n\t}\n\n\tif err := txn.Insert(\"index\", &IndexEntry{\"scaling_policy\", index}); err != nil {\n\t\treturn fmt.Errorf(\"index update failed: %v\", err)\n\t}\n\n\treturn nil\n}\n\n// ScalingPolicies returns an iterator over all the scaling policies\nfunc (s *StateStore) ScalingPolicies(ws memdb.WatchSet) (memdb.ResultIterator, error) {\n\ttxn := s.db.ReadTxn()","sourceCodeStart":7192,"sourceCodeEnd":7228,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L7192-L7228","documentation":"DeleteScalingPoliciesTxn refused to delete a scaling policy because no entry with the given ID exists in the scaling_policy table; deletions target concrete policies only.","triggerScenarios":"DELETE /v1/scaling/policy/<id> (or UPSERT path with delete intent) with a policy ID that was already deleted or never existed.","commonSituations":"Stale IDs cached by automation after the policy was recreated (IDs are regenerated on upsert); concurrent deletions; retrying a failed request that actually succeeded.","solutions":["Verify the scaling policy ID still exists before deleting","Drop stale IDs from the request","Retry if a concurrent deletion raced this one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"policies, _, err := client.Scaling().ListPolicies(nil)\nif err != nil { return err }\nfound := false\nfor _, p := range policies {\n    if p.ID == policyID { found = true; break }\n}\nif !found { return nil } // already gone; treat as idempotent success","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"scaling policy not found\") {\n    return nil // idempotent delete\n}","preventionTips":["Re-fetch policy IDs before deleting; upserting a job changes policy IDs.","Treat deletes as idempotent in cleanup scripts."],"tags":["nomad","state-store","scaling-policy","not-found"],"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"}