Skip to content

Fix/budget target client - #217

Merged
nfebe merged 2 commits into
devfrom
fix/budget-target-client-id
Aug 7, 2026
Merged

Fix/budget target client#217
nfebe merged 2 commits into
devfrom
fix/budget-target-client-id

Conversation

@austin047

Copy link
Copy Markdown
Collaborator

Description

Fix issues with Target client Id on the budget

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Budget targets went out under 'client_id' while the server validates
'targets.*.client_generated_id', so every offline-created budget with
targets failed with a 422 and quarantined.

Renaming the key alone is not enough: the queued payload is a snapshot,
so a target created offline still carries a null id after its own entity
syncs, and the server only ever attaches targets by numeric id. The
handler now re-resolves targets from local before pushing, defers the
push while any target is still unresolved (matching how transactions
gate on their category and wallet), and declares budget's dependency on
category, wallet and group so those push first.

Also fixes getLocalByClientId/getLocalByServerId dropping targets
entirely, which would have pushed a budget with its targets cleared.
A PDF export over the server's 100-row cap came back as a helpful 422
telling the user to narrow the range or pick another format, but the
app showed a generic unknown error: the datasource skipped the shared
error handler, and the JSON error body arrived as bytes so the message
extraction never matched. Downloads now route through the handler and
byte bodies are decoded before reading the message.

The finished export also only opened the share sheet, so dismissing it
lost the file with no copy anywhere the user could find. A ready export
now offers Save alongside Share; saving goes through the system file
picker, which needs no storage permission and confirms with the file
name.
@sourceant

sourceant Bot commented Aug 7, 2026

Copy link
Copy Markdown

Code Review Summary

This PR addresses synchronization issues with budgets by ensuring that budget targets (categories, wallets) are correctly resolved before syncing to the server. It fixes the payload key for targets and implements a deferred sync mechanism to wait for dependencies. Additionally, it improves the export user experience and error handling for binary responses.

🚀 Key Improvements

  • Implemented shouldPersistRemote in BudgetSyncHandler to ensure relational integrity during sync.
  • Updated BudgetSyncHandler to re-resolve target IDs from the local database before pushing, preventing stale ID errors.
  • Fixed the JSON key name for budget targets to client_generated_id to match server expectations.
  • Enhanced ErrorHandler to handle JSON error bodies wrapped in binary responses.
  • Added direct file saving capabilities to the history screen using a system file picker.

💡 Minor Suggestions

  • In ErrorHandler._decodeBody, returning the original data on decode failure would preserve the response for logging.
  • Corrected a minor typo in a test case.

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

Review complete. No specific code suggestions were generated. See the overview comment for a summary.

@nfebe
nfebe merged commit 2438509 into dev Aug 7, 2026
3 checks passed
@nfebe
nfebe deleted the fix/budget-target-client-id branch August 7, 2026 11:34
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