Skip to content

bug: reject non-finite numbers in JSON and NDJSON contracts #342

Description

@codeforester

Problem

The public JSON serializers use Python's permissive NaN/Infinity defaults. They can report successful output containing tokens rejected by strict JSON consumers such as JavaScript JSON.parse, undermining the advertised cross-language machine boundary.

Verified evidence

Reviewed on 2026-09-12 at 7faf347a5b90969e169c88f3ac18e7202d142dd0; the local checkout matches GitHub main.

stream = io.StringIO()
base_cli.NdjsonWriter(stream).write({"value": float("nan")})
print(stream.getvalue())
# {"schema_version":1,"schema":"base-cli.record","record":{"value":NaN}}

render_records(..., requested_format="json") and dumps_envelope(success_envelope(run_id=None, details={"value":float("inf")})) have the same permissive serialization path. Python json.loads accepts these extensions, so round-trip tests using only Python miss the violation.

Sources:

Acceptance criteria

  • Choose and document strict handling for NaN and positive/negative infinity (prefer rejecting with a clear error rather than silently changing data).
  • Serialize a full record before writing it so an invalid record does not leave a partial NDJSON line.
  • Test all public JSON/envelope/NDJSON emitters with nested non-finite values.
  • Use a strict parser, including the Node contract path, to reject nonstandard output.

Project fields

  • Status: Backlog
  • Priority: P2
  • Area: CLI
  • Initiative: v1.0 Readiness
  • Size: S
  • Assignee: @codeforester
  • Milestone: v1.0.0
  • Target date: unscheduled

Activity

  1. added this to the v1.0.0 milestone on Sep 12, 2026
  2. self-assigned this
    on Sep 12, 2026
  3. added theissue type on Sep 12, 2026
  4. moved this to Backlog in base-clion Sep 12, 2026
  5. moved this from Backlog to In Progress in base-clion Sep 18, 2026
  6. moved this from In Progress to Done in base-clion Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions