{"record":{"id":"a241d48abbfd1b00","repo":"gastownhall/beads","slug":"serializing-waits-for-metadata-w-a241d4","errorCode":null,"errorMessage":"serializing waits-for metadata: %w","messagePattern":"serializing waits-for metadata: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/batch_apply.go","lineNumber":389,"sourceCode":"\t\t}\n\t\treturn metadata, nil\n\t}\n\tmeta := types.WaitsForMeta{}\n\tif trimmed != \"\" && trimmed != \"{}\" {\n\t\tif err := json.Unmarshal([]byte(trimmed), &meta); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"waits-for metadata is not a well-formed gate object: %w\", err)\n\t\t}\n\t}\n\tif meta.Gate == \"\" {\n\t\tmeta.Gate = types.WaitsForAllChildren\n\t}\n\tif !types.IsValidWaitsForGate(meta.Gate) {\n\t\treturn \"\", fmt.Errorf(\"waits-for gate %q is neither %q nor %q\",\n\t\t\tmeta.Gate, types.WaitsForAllChildren, types.WaitsForAnyChildren)\n\t}\n\traw, err := json.Marshal(meta)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"serializing waits-for metadata: %w\", err)\n\t}\n\treturn string(raw), nil\n}\n","sourceCodeStart":371,"sourceCodeEnd":393,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/batch_apply.go#L371-L393","documentation":"After validating the gate, normalizeApplyEdgeMetadata re-marshals the WaitsForMeta struct to canonical JSON. This error wraps a json.Marshal failure, which is practically unreachable for WaitsForMeta (no channels/funcs/cycles) but is defensively reported if serialization fails.","triggerScenarios":"json.Marshal of the populated WaitsForMeta returns an error — only possible if the type gains unsupported fields (e.g. channel, func, or cyclic data) or a custom MarshalJSON misbehaves.","commonSituations":"Essentially never hit by users; would appear after a library change to WaitsForMeta or a custom marshaler bug.","solutions":["Report as a library bug if seen with stock types","Check for a custom MarshalJSON on WaitsForMeta or its fields that returns an error","Verify the types version matches what the storage layer expects"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"serializing waits-for metadata\") {\n\treturn fmt.Errorf(\"library bug: canonicalizing waits-for metadata failed: %w\", err)\n}","preventionTips":["Treat this as a library-level bug and report it","Keep types.WaitsForMeta free of unmarshalable fields","Pin a known-good version of the storage package"],"tags":["json","serialization","waits-for"],"backgroundTag":"json-serialization-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}