Skip to content

fix(shipbob): treat empty-body HTTP errors as cancel failures - #13517

Merged
kodjima33 merged 4 commits into
BasedHardware:mainfrom
Nukeys:fix/shipbob-cancel-empty-error
Sep 12, 2026
Merged

kodjima33 merged 4 commits into
BasedHardware:mainfrom
Nukeys:fix/shipbob-cancel-empty-error

Conversation

@Nukeys

@Nukeys Nukeys commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What

cancel_wro treated a failed request as success when the error
message was an empty string (HTTP error with blank body). It now
fails on any error/status_code key and on a null response.

Why

Closes #13183.

Test plan

  • Manual review of empty-string error path
  • No new public API

Failure-Class: none

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/omi-shipbob-app/main.py Resolved
@Nukeys

Nukeys commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Fixed: fallback now only formats HTTP {status} when status_code is present; otherwise it reports a generic failure.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Nukeys — real bug, correct diagnosis, and the right scope. I verified the fix against make_shipbob_request and ShipBob's documented cancel contract before commenting on specifics.

What checks out:

  • make_shipbob_request (plugins/omi-shipbob-app/main.py:143-178) returns exactly four shapes: parsed JSON on 200/201 (L171), {"error": response.text, "status_code": N} on other statuses (L175 — a blank body yields error: ""), {"error": str(e)} on exception (L178), and None when auth headers are missing or the method is unknown (L155/L169). The old truthiness check (result.get("error"), base L803-805) let both "" and None fall through to **WRO #… has been cancelled.** — a false success on precisely the paths where users can least afford it.
  • The new guard (L806-815) classifies all four shapes correctly, and the HTTP {status} / "ShipBob request failed" fallbacks keep the message informative when the body is blank. The follow-up commit addressing the interim "HTTP None" output was the right call.
  • No false-failure risk for genuine successes: ShipBob documents POST /2.0/receiving/{id}/cancel as 200 returning the full WRO object, and that schema contains no error/status_code fields, so a real success can never trip the new predicate.
  • Failure-Class: none in the PR body validates cleanly with scripts/failure-class validate at this head.

What's missing — the regression test:

The repo's Definition of Done requires bug fixes to land with the regression test that would have caught the bug, and #13183 itself proposed hermetic coverage for the empty-body failure plus ordinary failure/success controls. The pattern exists a couple of plugins over: plugins/omi-frankfurter-app/test_main.py exercises tool handlers through fastapi.testclient with mocked transport, and .github/checks-manifest.yaml wires plugin tests into both lanes (see the hacker-news-tests / usgs-earthquake-tests entries with plugins/<app>/** triggers). A test_main.py here covering empty-body 500 → error, None → error, non-empty error → surfaced, and 200 WRO object → success would close the loop and give this plugin its first CI coverage (no checks have run on this PR yet).

One scope note — not blocking, and please don't expand this PR for it: the same truthiness pattern is still live in tool_create_wro (L695-698 — an empty-body error currently renders as a created WRO with id Unknown) and the read handlers (tool_get_wros L753, tool_get_orders L855). A follow-up issue, or lifting the guard into the helper, would finish what #13183 started; the cancel-only scope here matches the issue's compact-scope proposal, so keeping this PR narrow is right.

Requesting changes only for the test — the fix itself is correct and tightly scoped. Once the test lands this should be a quick re-review.


by AI on behalf of David — leaving the final merge sign-off to a human maintainer; no product decision needed beyond that.

@Git-on-my-level Git-on-my-level added needs-tests PR introduces logic that should be covered by tests python labels Sep 12, 2026
@Nukeys

Nukeys commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Added plugins/omi-shipbob-app/test_main.py covering empty-body 500, None result, non-empty error, and 200 success via fastapi TestClient with mocked transport. Ready for re-review.

@Nukeys

Nukeys commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level Ready for re-review. All requested changes are pushed on the latest head.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Community bug-fix 5/5: error-classification fix verified against make_shipbob_request's 4 return shapes; regression tests now added addressing prior needs-tests gap.

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

Labels

needs-tests PR introduces logic that should be covered by tests python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ShipBob cancellation reports success for empty-body HTTP errors

3 participants