Skip to content

[codex] Share staging dry-run response parsing#889

Open
TruongIKPK wants to merge 1 commit into
ramimbo:mainfrom
TruongIKPK:codex/mergework-staging-post-helper-846
Open

[codex] Share staging dry-run response parsing#889
TruongIKPK wants to merge 1 commit into
ramimbo:mainfrom
TruongIKPK:codex/mergework-staging-post-helper-846

Conversation

@TruongIKPK
Copy link
Copy Markdown

@TruongIKPK TruongIKPK commented Jun 4, 2026

Refs #846

Summary:

  • extracted shared _parse_object_response for staging dry-run HTTP posts
  • kept status raising and non-object JSON rejection behavior unchanged
  • added focused regression coverage for non-object JSON responses

Validation:

  • ..venv\Scripts\python -m pytest tests/test_staging_webhook_dry_run.py -q
  • ..venv\Scripts\python -m ruff check scripts/staging_webhook_dry_run.py tests/test_staging_webhook_dry_run.py
  • ..venv\Scripts\python -m ruff format --check scripts/staging_webhook_dry_run.py tests/test_staging_webhook_dry_run.py
  • ..venv\Scripts\python -m mypy scripts/staging_webhook_dry_run.py
  • git diff --check

Duplicate/scope check:

  • checked open PRs before submission; none touched scripts/staging_webhook_dry_run.py or tests/test_staging_webhook_dry_run.py
  • no ledger, wallet, treasury, payout, admin-token, private data, bridge/exchange/cash-out, MRWK price, or secret behavior changed

Summary by CodeRabbit

  • Refactor

    • Consolidated JSON response parsing and validation logic to eliminate code duplication across webhook request handlers.
  • Tests

    • Added test coverage to verify error handling for non-object JSON responses.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a63fb22a-2b92-4e76-b84f-1a45888e5f52

📥 Commits

Reviewing files that changed from the base of the PR and between d4d0e48 and 316e578.

📒 Files selected for processing (2)
  • scripts/staging_webhook_dry_run.py
  • tests/test_staging_webhook_dry_run.py

📝 Walkthrough

Walkthrough

This PR refactors HTTP response handling in the staging webhook dry-run script to eliminate duplicated JSON parsing and validation logic. Two client functions now delegate to a centralized _parse_object_response helper. A new test verifies the helper correctly rejects non-object JSON payloads.

Changes

HTTP Response Parsing Refactoring

Layer / File(s) Summary
Centralized response parsing in HTTP client functions
scripts/staging_webhook_dry_run.py
_post_json and _post_webhook are refactored to delegate response handling to _parse_object_response, removing inline raise_for_status() calls and JSON object validation that were previously duplicated across both functions.
Non-object JSON validation test
tests/test_staging_webhook_dry_run.py
Test imports are extended to include httpx and _parse_object_response; a new test case verifies that _parse_object_response raises RuntimeError when the HTTP response body contains valid JSON that is not an object (e.g., a list).
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Bounty Pr Focus ⚠️ Warning Commit adds 165 files (entire app/, docs/, migrations/) but PR claims +16/-15 line refactor of only two files. Massive scope violation unrelated to stated changes. Verify commit scope matches PR description. If this is repository init, correct PR scope. Otherwise, extract only staging_webhook changes into separate commit.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title '[codex] Share staging dry-run response parsing' accurately describes the main change: extracting and sharing a response parsing helper function for staging dry-run HTTP posts.
Description check ✅ Passed The description covers the summary and evidence sections with clear intent, validation steps, and scope checks, though it deviates from the template format by omitting structured subsections like 'Confusion/bug addressed' and 'Intended files'.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Mergework Public Artifact Hygiene ✅ Passed No investment, price, cash-out, fabricated payout, or private security claims found in the PR. MRWK correctly described as native ledger coin supporting future snapshots/bridges/onchain claims.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@xiefuzheng713-alt xiefuzheng713-alt left a comment

Choose a reason for hiding this comment

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

Reviewed current head 316e578c78b6c64e247afbc489bb74d73b96bc87 as a non-author.

Evidence checked:

  • inspected scripts/staging_webhook_dry_run.py and tests/test_staging_webhook_dry_run.py;
  • confirmed _post_json() and _post_webhook() now share _parse_object_response() while preserving URL validation before posting, HTTP raise_for_status(), JSON parsing, and non-object JSON rejection behavior;
  • confirmed the webhook path still signs the compact JSON body and sends the same GitHub delivery/event/signature headers before parsing the response;
  • confirmed the new regression test covers non-object JSON responses with an httpx.Response carrying a request, so status handling remains realistic;
  • verified GitHub reports mergeStateStatus=CLEAN, hosted Quality/readiness/docs/image success, and CodeRabbit success;
  • confirmed there were no prior human reviews on this head before posting this review.

Validation run on this exact head:

  • uv run --python 3.12 --extra dev python -m pytest tests/test_staging_webhook_dry_run.py -q -> 14 passed.
  • uv run --python 3.12 --extra dev ruff check scripts/staging_webhook_dry_run.py tests/test_staging_webhook_dry_run.py -> passed.
  • uv run --python 3.12 --extra dev ruff format --check scripts/staging_webhook_dry_run.py tests/test_staging_webhook_dry_run.py -> 2 files already formatted.
  • uv run --python 3.12 --extra dev mypy scripts/staging_webhook_dry_run.py -> success.
  • uv run --python 3.12 --extra dev python scripts/docs_smoke.py -> docs smoke ok.
  • git diff --check origin/main...HEAD -> clean.
  • git merge-tree --write-tree origin/main HEAD -> clean tree 3f62f64d86056985ae17934143787b441c021fe0.

No blocker found. Scope stays inside staging dry-run response parsing/tests and does not touch ledger, wallet, treasury, payout, admin-token behavior, private data, secrets, exchange, bridge, cash-out, or MRWK price behavior.

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.

2 participants