Skip to content

feat(queries): print JSON message for 4xx/422 responses before HTTPError - #239

Merged
ghinks merged 1 commit into
mainfrom
feat/print-4xx-errors
Jun 23, 2026
Merged

feat(queries): print JSON message for 4xx/422 responses before HTTPError#239
ghinks merged 1 commit into
mainfrom
feat/print-4xx-errors

Conversation

@ghinks

@ghinks ghinks commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

When GitHub returns a 4xx response (such as 422 Validation Failed), the response includes a JSON body with a message field. This PR adds a helper function to extract and print the message field before raising the status exception in _make_pr_request_with_retry.

Changes

  • Added _print_4xx_error_message to reviewtally/queries/get_prs.py to check for 4xx status codes, parse the JSON body, and print the message field.
  • Integrated helper into _make_pr_request_with_retry right before calling raise_for_status.
  • Added unit tests in tests/test_get_prs.py to assert correct printing for 422 responses and handle cases without messages or with invalid JSON.

Verification

  • poetry run pytest -m "not integration" passed successfully.
  • poetry run ruff check . and poetry run ruff format . passed successfully.

@ghinks
ghinks merged commit 5cd5a73 into main Jun 23, 2026
9 checks passed
@ghinks
ghinks deleted the feat/print-4xx-errors branch June 23, 2026 20:12
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