affaan-m/ECC · error · ValueError

unknown bundle fields

Error message

unknown bundle fields

What it means

_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.

Solutions

  1. Remove the extra keys from the bundle section before validation
  2. Check the validator (_snapshot/_binding/etc.) to see which optional keys are allowed and use those exact names
  3. Regenerate the bundle using the matching library version so schema and validator agree

Example fix

// before
rate = {"numerator": 24, "denominator": 1, "label": "film"}
// after
rate = {"numerator": 24, "denominator": 1}
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = REQUIRED | OPTIONAL
extra = set(section.keys()) - ALLOWED
assert not extra, f"unknown fields: {extra}"

Try / catch

try:
    validate_application_bundle(raw)
except ValueError as e:
    if "unknown bundle fields" in str(e):
        print("strip or rename extra fields to match the current schema")
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Bundles exported by an older/newer library version, hand-added metadata fields, or misspelled key names that dodge the required-set check.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/30f62ff38b3c03f7. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/integration.py:43

_MAX_JSON = 8 * 1024 * 1024


def _canonical(value: Any) -> bytes:
    try:
        return json.dumps(value, sort_keys=True, separators=(",", ":"), allow_nan=False).encode()
    except (TypeError, ValueError, RecursionError) as exc:
        raise ValueError("bundle values must be finite JSON data") from exc


def _digest(value: Any) -> str:
    return hashlib.sha256(_canonical(value)).hexdigest()


def _object(value: Any, required: set[str], optional: set[str] | None = None) -> dict:
    if not isinstance(value, dict) or not required <= value.keys():
        raise ValueError("missing required bundle fields")
    if value.keys() - required - (optional or set()):
        raise ValueError("unknown bundle fields")
    return value


def _text(value: Any) -> str:
    if not isinstance(value, str) or not value.strip():
        raise ValueError("nonempty text required")
    return value


def _integer(value: Any, minimum: int = 0) -> int:
    if type(value) is not int or value < minimum:
        raise ValueError("frame/count must be an exact integer in range")
    return value


def _rate(value: Any) -> tuple[int, int]:
    _object(value, {"numerator", "denominator"})
    n, d = (_integer(value[k], 1) for k in ("numerator", "denominator"))

View on GitHub (pinned to 8321021c54)