{"record":{"id":"b8ab877d95523074","repo":"affaan-m/ECC","slug":"missing-required-bundle-fields","errorCode":null,"errorMessage":"missing required bundle fields","messagePattern":"missing required bundle fields","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/integration.py","lineNumber":41,"sourceCode":"_REQUIRED = {\"baseline\", \"source\", \"audio\", \"protected_intervals\"}\n_OPTIONAL = {\"candidates\", \"inserts\", \"historical_receipts\"}\n_MAX_JSON = 8 * 1024 * 1024\n\n\ndef _canonical(value: Any) -> bytes:\n    try:\n        return json.dumps(value, sort_keys=True, separators=(\",\", \":\"), allow_nan=False).encode()\n    except (TypeError, ValueError, RecursionError) as exc:\n        raise ValueError(\"bundle values must be finite JSON data\") from exc\n\n\ndef _digest(value: Any) -> str:\n    return hashlib.sha256(_canonical(value)).hexdigest()\n\n\ndef _object(value: Any, required: set[str], optional: set[str] | None = None) -> dict:\n    if not isinstance(value, dict) or not required <= value.keys():\n        raise ValueError(\"missing required bundle fields\")\n    if value.keys() - required - (optional or set()):\n        raise ValueError(\"unknown bundle fields\")\n    return value\n\n\ndef _text(value: Any) -> str:\n    if not isinstance(value, str) or not value.strip():\n        raise ValueError(\"nonempty text required\")\n    return value\n\n\ndef _integer(value: Any, minimum: int = 0) -> int:\n    if type(value) is not int or value < minimum:\n        raise ValueError(\"frame/count must be an exact integer in range\")\n    return value\n\n\ndef _rate(value: Any) -> tuple[int, int]:","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/integration.py#L23-L59","documentation":"_object validates that a value is a dict containing at least the required keys; if the value is not a dict or is missing any required key it raises ValueError('missing required bundle fields'). It is the shared structural validator for all bundle sub-objects (rate, artifact, snapshot, binding, etc.).","triggerScenarios":"Any bundle section passed to build_application_bundle/validate_application_bundle missing a required key, e.g. a snapshot without 'fps' or 'duration_frames', or a binding missing 'source_range'.","commonSituations":"Hand-written bundle JSON missing a field, older bundles produced by a previous schema version, or typos in key names ('framerate' vs 'fps').","solutions":["Diff the offending object's keys against the required set in the corresponding validator (_snapshot, _binding, etc.) and add the missing field","Regenerate the bundle with the current version of build_application_bundle instead of hand-editing","Add a pre-flight check that each section contains the required keys before calling validate"],"exampleFix":"// before\nsnapshot = {\"fps\": {\"numerator\": 24, \"denominator\": 1}}\n// after\nsnapshot = {\"fps\": {\"numerator\": 24, \"denominator\": 1}, \"duration_frames\": 240}","handlingStrategy":"validation","validationCode":"REQUIRED_SNAPSHOT = {\"fps\", \"duration_frames\"}\nmissing = REQUIRED_SNAPSHOT - snapshot.keys()\nassert not missing, f\"snapshot missing fields: {missing}\"","typeGuard":"def has_required(obj, required: set) -> bool:\n    return isinstance(obj, dict) and required <= obj.keys()","tryCatchPattern":"try:\n    bundle = validate_application_bundle(raw)\nexcept ValueError as e:\n    if \"missing required bundle fields\" in str(e):\n        print(\"bundle schema mismatch; regenerate with build_application_bundle\")\n    else:\n        raise","preventionTips":["Always construct bundles via build_application_bundle rather than hand-writing dicts","Version your bundles and validate old ones after schema changes","Key names via constants, not string literals, to avoid typos"],"tags":["schema","validation","bundle"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}