fix: Use correct GraphQL field names in UpdateTransaction mutation#14
Merged
eshaffer321 merged 1 commit intomainfrom Oct 17, 2025
Merged
fix: Use correct GraphQL field names in UpdateTransaction mutation#14eshaffer321 merged 1 commit intomainfrom
eshaffer321 merged 1 commit intomainfrom
Conversation
PROBLEM: The Update() method was sending incorrect field names to Monarch's API: - Used "categoryId" instead of "category" - Used "merchant" instead of "name" This caused Monarch to reject requests with BAD_REQUEST errors, breaking single-category transaction updates since the October 2024 refactoring. SOLUTION (TDD Red-Green-Refactor): 1. RED: Added TestTransactionService_Update_CorrectFieldNames that verifies the correct field names are used, matching the Python reference implementation 2. GREEN: Fixed transactions.go lines 155, 158 to use correct field names 3. REFACTOR: Verified all 39 tests pass with no regressions VERIFICATION: - Test-driven: New test prevents regression - Reference: Matches Python SDK field names (monarchmoney library) - Integration: Tested with real Walmart order, now succeeds - Database: Order 200013901907426 status changed from failed to success Changes: - pkg/monarch/transactions.go: Changed "categoryId" → "category", "merchant" → "name" - pkg/monarch/transactions_test.go: Added comprehensive test case Fixes single-category transaction update feature that has been broken in production.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (43.18%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
==========================================
+ Coverage 41.80% 43.18% +1.38%
==========================================
Files 15 15
Lines 2239 2239
==========================================
+ Hits 936 967 +31
+ Misses 1236 1198 -38
- Partials 67 74 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
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
The
Update()method was using incorrect GraphQL field names when updating transactions:"categoryId"instead of"category""merchant"instead of"name"This caused Monarch's API to reject requests with
BAD_REQUESTerrors, breaking single-category transaction updates since the October 2024 refactoring.Solution
Fixed using TDD Red-Green-Refactor:
🔴 RED Phase
TestTransactionService_Update_CorrectFieldNamesthat verifies correct field names🟢 GREEN Phase
transactions.golines 155, 158 to use correct field names:"categoryId"→"category""merchant"→"name"🔵 REFACTOR Phase
Reference
Field names verified against the Python monarchmoney library (lines 2574-2575), which is the reference implementation.
Verification
200013901907426status changed fromfailedtosuccessFiles Changed
pkg/monarch/transactions.go: Fixed field names (2 lines)pkg/monarch/transactions_test.go: Added comprehensive test (113 lines)Impact
Fixes critical bug in single-category transaction updates that has been broken in production.