Fix delete_transaction_rule reporting successful deletions as failures - #86
Open
ahnj wants to merge 1 commit into
Open
Fix delete_transaction_rule reporting successful deletions as failures#86ahnj wants to merge 1 commit into
ahnj wants to merge 1 commit into
Conversation
Monarch's deleteTransactionRule mutation returns `deleted: false` with no
errors even when the rule was successfully removed. Verified against the
live API: deleting four real rules returned `deleted: false` every time,
while the rules were in fact gone (confirmed by re-querying the rule list
and by the total count dropping from 322 to 318).
The existing guard treated that flag as authoritative, so every successful
deletion reported `{"success": false, "message": "Rule was not deleted"}`.
That is worse than a cosmetic bug: the tool reports a destructive operation
as having not happened, inviting the caller to retry or to believe stale
state is still present.
Genuine failures never reach that branch. Deleting a non-existent rule
raises TransportQueryError ("Not found") from the GraphQL layer, which the
surrounding except block already converts into an error result. The only
in-payload failure signal worth honouring is an explicit `errors` object,
which is left in place.
The existing "not found" test passed because it mocked `deleted: false`
*together with* an errors object, so the errors branch caught it first.
Added a test covering the real-world shape (`deleted: false`, `errors: None`);
it fails before this change and passes after.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTJGjJh4qNHBGWdZW3UDPo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
delete_transaction_rulereturns{"success": false, "message": "Rule was not deleted"}for deletions that actually succeed.Monarch's
deleteTransactionRulemutation returnsdeleted: falsewith no errors even when the rule was removed. The current guard treats that flag as authoritative:This is more than cosmetic — the tool reports a completed destructive operation as not having happened, which invites the caller to retry or to act on state they believe is still present.
Verification against the live API
Deleted four real rules. Every call returned
deleted: false; all four were genuinely gone, confirmed by re-querying the rule list (the IDs were absent) and by the total count dropping from 322 to 318.Genuine failures never reach that branch. Deleting a non-existent rule raises
TransportQueryErrorfrom the GraphQL layer:which the surrounding
except Exceptionalready turns into an error result.Change
Drop the
deletedcheck. The expliciterrorspayload check is left in place as the only trustworthy in-payload failure signal.Tests
test_delete_rule_not_foundpassed before and after because it mocksdeleted: falsetogether with an errors object, so the errors branch catches it first — the real-world shape was never covered.Added
test_delete_rule_success_with_false_deleted_flagfordeleted: false+errors: None. It fails before this change and passes after. Full suite: 223 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01KTJGjJh4qNHBGWdZW3UDPo