{"record":{"id":"8b1088557dea4457","repo":"hashicorp/nomad","slug":"failed-to-decode-alloc-v","errorCode":null,"errorMessage":"failed to decode alloc: %v","messagePattern":"failed to decode alloc: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/state/db_bolt.go","lineNumber":278,"sourceCode":"\t\t// No allocs\n\t\treturn allocs, errs\n\t}\n\n\t// Create a cursor for iteration.\n\tc := allocationsBkt.BoltBucket().Cursor()\n\n\t// Iterate over all the allocation buckets\n\tfor k, _ := c.First(); k != nil; k, _ = c.Next() {\n\t\tallocID := string(k)\n\t\tallocBkt := allocationsBkt.Bucket(k)\n\t\tif allocBkt == nil {\n\t\t\terrs[allocID] = fmt.Errorf(\"missing alloc bucket\")\n\t\t\tcontinue\n\t\t}\n\n\t\tvar ae allocEntry\n\t\tif err := allocBkt.Get(allocKey, &ae); err != nil {\n\t\t\terrs[allocID] = fmt.Errorf(\"failed to decode alloc: %v\", err)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Handle upgrade path\n\t\tae.Alloc.Canonicalize()\n\t\tae.Alloc.Job.Canonicalize()\n\n\t\tallocs = append(allocs, ae.Alloc)\n\t}\n\n\treturn allocs, errs\n}\n\n// PutAllocation stores an allocation or returns an error.\nfunc (s *BoltStateDB) PutAllocation(alloc *structs.Allocation, opts ...WriteOption) error {\n\treturn s.updateWithOptions(opts, func(tx *boltdd.Tx) error {\n\t\t// Retrieve the root allocations bucket\n\t\tallocsBkt, err := tx.CreateBucketIfNotExists(allocationsBucketName)","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/state/db_bolt.go#L260-L296","documentation":"In getAllAllocations, allocBkt.Get fails to decode the serialized allocEntry for one allocation (deserialization/corruption); the error is recorded per alloc ID in the errs map and the loop skips to the next allocation.","triggerScenarios":"Thrown at client/state/db_bolt.go:278 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the state DB for corrupted alloc entries","Re-adopt or re-run the affected allocation after repair","Log and continue for remaining allocs as the code already does"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}