Skip to content

fix: reject non-standard JSON constants in NDJSON exports - #130

Open
andrewluke-dev wants to merge 1 commit into
prooflinedev:mainfrom
andrewluke-dev:feature/sdk-improvement
Open

andrewluke-dev wants to merge 1 commit into
prooflinedev:mainfrom
andrewluke-dev:feature/sdk-improvement

Conversation

@andrewluke-dev

Copy link
Copy Markdown

Summary

Fixes NDJSON export parsing in the Proofline Python SDK by rejecting non-standard JSON numeric constants (NaN, Infinity, and -Infinity).

Problem

Python's default json.loads() implementation accepts non-standard numeric constants that are not permitted by the JSON specification (RFC 8259).

Consequently, malformed NDJSON export responses could be accepted instead of raising a ProoflineError.

Solution

  • Introduced a dedicated JSON constant rejection helper.
  • Configured NDJSON decoding through the parse_constant argument.
  • Preserved the existing SDK error-handling mechanism.
  • Maintained compatibility with valid JSON values.
  • Avoided changes to generated code and public API signatures.

Regression coverage

Added 10 regression test cases covering:

  • Rejection of NaN, Infinity, and -Infinity.
  • Invalid constants in scalar values, arrays, and nested objects.
  • Successful decoding of valid numeric values, strings, and null values.

Validation

  • Full pytest suite: 228 passed
  • Ruff linting: passed
  • Ruff formatting: applied
  • Mypy type checking: passed
  • Git diff whitespace validation: passed

Impact

This change improves export data integrity and standards compliance across the SDK's five NDJSON export datasets.

Malformed numeric constants are rejected through the existing SDK error-handling mechanism rather than silently entering downstream applications.

Compatibility

  • No new dependencies.
  • No generated code modifications.
  • No public API signature changes.
  • Valid JSON responses retain their existing behavior.

AI assistance

AI was used to assist with implementation and documentation.

@andrewluke-dev
andrewluke-dev marked this pull request as ready for review November 27, 2026 16:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant