Fix Reports API status check to recognize DONE instead of COMPLETED - #68
Merged
Merged
Conversation
ReportStatusResponse::isReady() checked the report status against COMPLETED / READY, but Bring's Reports API never returns those values. It reports NOT_DONE while a report is still generating and DONE once it is ready to download (the same contract the legacy StatusOfReport client encodes with `getStatus() === 'DONE'`). Because isReady() never matched a real response, every polled report looked perpetually unfinished: pending-report pollers downloaded and processed nothing and never flipped their tracking rows off `pending`, so the tracking table filled with reports that were never collected. Match the real API by treating DONE (case-insensitively) as ready. Also fall back through the real xmlUrl / xlsUrl fields when mapping the download URL, since Bring has no `downloadUrl` field. Adds a regression test covering the ready/not-ready statuses and the URL fallback.
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.
What
Fixed the
ReportStatusResponse::isReady()method to correctly recognize Bring's actual report completion status (DONE) instead of the non-existent statuses (COMPLETED/READY). Also fixed thedownloadUrlfallback logic to properly usexmlUrlandxlsUrlfields from the actual API response.Why
The previous implementation checked for
COMPLETEDorREADYstatuses that Bring's Reports API never returns. The actual API returnsNOT_DONEwhile generating andDONEwhen ready. This caused all polled reports to appear perpetually unfinished, allowing pending-report tables to accumulate rows that were never collected.Additionally, the real API response exposes the finished report location via
xmlUrl/xlsUrlfields, notdownloadUrl. The fallback logic now correctly chains through these fields so the download URL isn't perpetually null on real responses.Test plan
ReportStatusResponseTest.phpcovering:DONEstatus recognition as readyNOT_DONEstatus as not readydownloadUrl→xmlUrl→xlsUrl)COMPLETED,READY)Bring docs link
https://developer.bring.com/api/reports
https://claude.ai/code/session_01JjoZoqzCvueSLzHbbhMo1Z