Skip to content

fix(clob): fail incomplete cancellations - #102

Open
Kewe63 wants to merge 1 commit into
Polymarket:mainfrom
Kewe63:fix/issue-91-cancellation-exit-status
Open

Kewe63 wants to merge 1 commit into
Polymarket:mainfrom
Kewe63:fix/issue-91-cancellation-exit-status

Conversation

@Kewe63

@Kewe63 Kewe63 commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

  • return a command error when a cancellation response contains any not_canceled entries
  • preserve the complete partial-result output in both table and JSON modes
  • keep fully successful and empty cancellation responses successful

Problem

Cancellation commands printed failed entries from the CLOB response but unconditionally returned success. Automation therefore received exit status 0 even when one or more orders remained open.

Approach

print_cancel_result continues to render the full response first, then returns an error when not_canceled is nonempty. All cancellation commands share this formatter, so the behavior applies consistently to single, batch, market, and cancel-all operations.

Tests

  • focused RED/GREEN regression: partial cancellation failed before the fix and passes after it
  • table and JSON partial-failure coverage
  • table and JSON complete-success coverage
  • cargo +1.91.1 fmt --check
  • cargo +1.91.1 clippy --locked --all-targets -- -D warnings
  • git diff --check

Risk

Low. Output remains available before the command returns an error; only the process success classification changes for responses that already report failed cancellations.

Fixes #91


Note

Low Risk
Only exit status changes when the response already included failed cancellations; output content and successful paths are unchanged.

Overview
CLOB cancel commands now exit with an error when the API reports any orders in not_canceled. Table and JSON output are unchanged and still show the full partial result before the process fails.

print_cancel_result checks not_canceled after rendering, so single, batch, market, and cancel-all flows that use this formatter get consistent non-zero exit codes for automation. Fully successful cancellations (empty not_canceled) still return success.

Unit tests cover partial failure and full success for both table and JSON output modes.

Reviewed by Cursor Bugbot for commit 8f67c72. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 8f67c72. Configure here.

Comment thread src/output/clob/orders.rs

if !result.not_canceled.is_empty() {
anyhow::bail!("one or more orders could not be canceled");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

JSON cancel failure emits two documents

Medium Severity

print_cancel_result writes the cancellation payload and then returns an error. In JSON mode, print_error also writes an error object to stdout, so scripts receive two concatenated JSON documents instead of a single result or error object.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8f67c72. Configure here.

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.

[Bug]: Cancellation failures still exit successfully

1 participant