affaan-m/ECC · error · ValueError
Invalid JSON at line
Error message
Invalid JSON at line {i}: {e} What it means
JSONL parse guard in parse_trace: a line in the observation trace is not valid JSON, so the event stream cannot be decoded. The offending 1-based line number and the decoder error are included; common causes are truncated writes or interleaved non-JSON log lines.
Solutions
- Open the trace at the reported line and fix or remove the malformed line
- Regenerate the trace; a partial line often means the recording process was killed mid-write
- Filter out non-JSON preamble lines before parsing if the source emits them
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at skills/skill-comply/scripts/parser.py:61 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/f3ec30cc69471e5b.
Report an issue: GitHub.
Appendix: source
Thrown at skills/skill-comply/scripts/parser.py:61
steps: tuple[Step, ...]
threshold_promote_to_hook: float
def parse_trace(path: Path) -> list[ObservationEvent]:
"""Parse a JSONL observation trace file into sorted events."""
if not path.is_file():
raise FileNotFoundError(f"Trace file not found: {path}")
text = path.read_text().strip()
if not text:
return []
events: list[ObservationEvent] = []
for i, line in enumerate(text.splitlines(), 1):
try:
raw = json.loads(line)
except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON at line {i}: {e}") from e
try:
events.append(ObservationEvent(
timestamp=raw["timestamp"],
event=raw["event"],
tool=raw["tool"],
session=raw["session"],
input=raw.get("input", ""),
output=raw.get("output", ""),
))
except KeyError as e:
raise ValueError(f"Missing required field {e} at line {i}") from e
return sorted(events, key=lambda e: e.timestamp)
def parse_spec(path: Path) -> ComplianceSpec:
"""Parse a YAML compliance spec file."""
if not path.is_file():View on GitHub (pinned to 8321021c54)