Skip to content

fix(api): validate traffic response containers - #125

Merged
HafidIdrissi merged 1 commit into
HafidIdrissi:mainfrom
Y2XNishan:fix-api-response-containers
Oct 22, 2026
Merged

HafidIdrissi merged 1 commit into
HafidIdrissi:mainfrom
Y2XNishan:fix-api-response-containers

Conversation

@Y2XNishan

Copy link
Copy Markdown
Contributor

Closes #25

Summary

  • Validate JSON containers for views, clones, referrers, and paths with endpoint-specific errors.
  • Preserve valid empty lists, extra response fields, existing request behavior, and row handling.

Validation

  • python -m pytest tests/test_api.py — 61 passed.
  • python -m pytest with a fresh checkout-local pytest temp directory — 126 passed, no skips.
  • git diff --check — passed.
  • Windows 11, Python 3.13.5. Python 3.9 compatibility was reviewed but Python 3.9 was not executed.

AI disclosure: OpenAI Codex assisted with implementation and validation. The contributor reviewed and approved the change.

@HafidIdrissi HafidIdrissi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete API/container change and regression tests against #25. The helper converts malformed successful JSON to endpoint-specific TrafficError without the original decoder context, requires object roots plus explicit list metrics for views/clones, and list roots for referrers/paths. Explicit empty lists and extra valid response fields remain accepted. Unsupported aggregation values are still rejected before requests; request headers, timeout/retry behavior and individual row handling are unchanged. Tests exercise the actual mocked HTTP-success decoding path, response closure and absence of sentinel body/token values in errors and formatted traceback. Individual daily-row validation and doctor behavior remain outside this PR as agreed.

Independent Windows/Python 3.11.9 verification on this exact head: python -m pytest tests/test_api.py -q passes 61 tests; python -m pytest -q passes 126 tests. All data/network responses are synthetic. Inspected current-head CI run 38871704188: 126 tests pass in each Windows/Ubuntu Python 3.9/3.12 job. No new runtime dependency or blocking correctness/security finding. No unresolved review thread. Approved.

@HafidIdrissi
HafidIdrissi merged commit cdeea0c into HafidIdrissi:main Oct 22, 2026
4 checks passed
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.

Report malformed API responses as actionable traffic errors

2 participants