hashicorp/nomad · warning
scaling policy not found
Error message
scaling policy not found
What it means
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.
Source
Thrown at nomad/state/state_store.go:7210
}
return err
}
// DeleteScalingPoliciesTxn is used to delete a set of scaling policies by ID.
func (s *StateStore) DeleteScalingPoliciesTxn(index uint64, ids []string, txn *txn) error {
if len(ids) == 0 {
return nil
}
for _, id := range ids {
// Lookup the scaling policy
existing, err := txn.First("scaling_policy", "id", id)
if err != nil {
return fmt.Errorf("scaling policy lookup failed: %v", err)
}
if existing == nil {
return fmt.Errorf("scaling policy not found")
}
// Delete the scaling policy
if err := txn.Delete("scaling_policy", existing); err != nil {
return fmt.Errorf("scaling policy delete failed: %v", err)
}
}
if err := txn.Insert("index", &IndexEntry{"scaling_policy", index}); err != nil {
return fmt.Errorf("index update failed: %v", err)
}
return nil
}
// ScalingPolicies returns an iterator over all the scaling policies
func (s *StateStore) ScalingPolicies(ws memdb.WatchSet) (memdb.ResultIterator, error) {
txn := s.db.ReadTxn()View on GitHub (pinned to 482b49bf1a)
Solutions
- Verify the scaling policy ID still exists before deleting
- Drop stale IDs from the request
- Retry if a concurrent deletion raced this one
Defensive patterns
Strategy: validation
Validate before calling
policies, _, err := client.Scaling().ListPolicies(nil)
if err != nil { return err }
found := false
for _, p := range policies {
if p.ID == policyID { found = true; break }
}
if !found { return nil } // already gone; treat as idempotent success Try / catch
if strings.Contains(err.Error(), "scaling policy not found") {
return nil // idempotent delete
} Prevention
- Re-fetch policy IDs before deleting; upserting a job changes policy IDs.
- Treat deletes as idempotent in cleanup scripts.
When it happens
Trigger: DELETE /v1/scaling/policy/<id> (or UPSERT path with delete intent) with a policy ID that was already deleted or never existed.
Common situations: Stale IDs cached by automation after the policy was recreated (IDs are regenerated on upsert); concurrent deletions; retrying a failed request that actually succeeded.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/4f2c3df61cda2089.
Report an issue: GitHub.