affaan-m/ECC · error · ValueError
bundle values must be finite JSON data
Error message
bundle values must be finite JSON data
What it means
_canonical serializes a bundle value to canonical JSON for hashing/digesting, using allow_nan=False. Any value that is not finite JSON data (sets, datetime, NaN/Infinity floats, cyclic structures) raises ValueError. This guarantees bundle digests are reproducible.
Solutions
- Convert non-JSON types to JSON-compatible ones (sets->lists, datetime->ISO strings, numpy scalars->int/float)
- Replace NaN/Infinity floats with None or explicit sentinel values before building the bundle
- Catch this error and dump repr(value) of bundle parts to locate the offending field
Example fix
// before
bundle = {"snapshot": {..., "captured_at": datetime.now()}}
// after
bundle = {"snapshot": {..., "captured_at": datetime.now().isoformat()}} Defensive patterns
Strategy: validation
Validate before calling
def ensure_json_finite(value):
json.dumps(value, allow_nan=False) # raises before build if not serializable Try / catch
try:
bundle = build_application_bundle(data)
except ValueError as e:
if "finite JSON" in str(e):
print("bundle contains non-JSON or non-finite values; inspect repr(data)")
else:
raise Prevention
- Convert sets/datetimes/numpy types to JSON-native equivalents before bundling
- Never use float('nan')/float('inf') in bundle data; use None or sentinels
- Run a trial json.dumps(value, allow_nan=False) smoke test on generated bundles
When it happens
Trigger: Passing non-JSON-serializable values into build_application_bundle or validate_application_bundle (e.g. a Python set, datetime, Decimal, float('nan'), float('inf'), or a self-referencing dict).
Common situations: Loading snapshots from a non-JSON source (yaml/DB) without converting types, hand-constructing bundle dicts with float('nan') for unknown fps, or leaving numpy scalar types in parsed data.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- application request must be a JSON object
- candidate configuration exceeds 1 MiB
- duplicate JSON field
- Failed to serialize
- gate.taskset_invalid
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/fccc86205de353bf.
Report an issue: GitHub.
Appendix: source
Thrown at skills/taste-application/scripts/tasteforge/integration.py:32
import os
import re
import stat
from fractions import Fraction
from pathlib import Path
from typing import Any
from urllib.parse import urlsplit
_REQUIRED = {"baseline", "source", "audio", "protected_intervals"}
_OPTIONAL = {"candidates", "inserts", "historical_receipts"}
_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 valueView on GitHub (pinned to 8321021c54)