{"record":{"id":"30f62ff38b3c03f7","repo":"affaan-m/ECC","slug":"unknown-bundle-fields","errorCode":null,"errorMessage":"unknown bundle fields","messagePattern":"unknown bundle fields","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/integration.py","lineNumber":43,"sourceCode":"_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]:\n    _object(value, {\"numerator\", \"denominator\"})\n    n, d = (_integer(value[k], 1) for k in (\"numerator\", \"denominator\"))","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/integration.py#L25-L61","documentation":"_object also enforces a closed schema: any key that is neither required nor declared optional raises ValueError('unknown bundle fields'). This prevents silently ignoring typos or stale fields in bundle sections.","triggerScenarios":"Passing a bundle section with extra keys, e.g. a rate object containing 'label', or a snapshot carrying a legacy field removed in the current schema.","commonSituations":"Bundles exported by an older/newer library version, hand-added metadata fields, or misspelled key names that dodge the required-set check.","solutions":["Remove the extra keys from the bundle section before validation","Check the validator (_snapshot/_binding/etc.) to see which optional keys are allowed and use those exact names","Regenerate the bundle using the matching library version so schema and validator agree"],"exampleFix":"// before\nrate = {\"numerator\": 24, \"denominator\": 1, \"label\": \"film\"}\n// after\nrate = {\"numerator\": 24, \"denominator\": 1}","handlingStrategy":"validation","validationCode":"ALLOWED = REQUIRED | OPTIONAL\nextra = set(section.keys()) - ALLOWED\nassert not extra, f\"unknown fields: {extra}\"","typeGuard":null,"tryCatchPattern":"try:\n    validate_application_bundle(raw)\nexcept ValueError as e:\n    if \"unknown bundle fields\" in str(e):\n        print(\"strip or rename extra fields to match the current schema\")\n    else:\n        raise","preventionTips":["Only add fields that the current schema's optional set declares","Strip internal/debug metadata before writing bundle files","When upgrading library versions, re-export old bundles instead of editing them"],"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"}