Skip to content

OUT-3709: drop placeholder errorMessage on stale PENDING flip#246

Merged
SandipBajracharya merged 1 commit into
masterfrom
OUT-3709
May 12, 2026
Merged

OUT-3709: drop placeholder errorMessage on stale PENDING flip#246
SandipBajracharya merged 1 commit into
masterfrom
OUT-3709

Conversation

@SandipBajracharya
Copy link
Copy Markdown
Collaborator

Summary

  • flipStalePendingToFailed previously stamped errorMessage: 'Stale PENDING claim — worker did not finalise in time' onto qb_sync_logs when recovering stale PENDING rows.
  • SyncService.intiateSync reads currentLog.errorMessage when reporting to Sentry on the final retry attempt (sync.service.ts:479), so that placeholder was being surfaced as if it were the real exception — misleading on-call (e.g. ACCOUNTING-SYNC-3M).
  • Drop the placeholder. The flip still sets status: FAILED and category: OTHERS; the first retry that actually throws will populate errorMessage with the real reason via updateFailedSyncLog.

Out of scope

  • Silent early-return paths in processInvoiceDeleted / processInvoiceVoided (!invoiceSync.customer) that never overwrite errorMessage on retry. With this change, those rows now surface null in Sentry instead of the misleading placeholder — uninformative, but no longer misleading. Cleanup deferred to a follow-up ticket.

Test plan

  • Existing unit + integration tests still pass (yarn test).
  • Lint + prettier clean (yarn lint:check, yarn prettier:check).
  • Manual: in next stale-recovery cycle, verify newly flipped rows have error_message = NULL and the next retry either fills it with a real exception or flips to SUCCESS.

🤖 Generated with Claude Code

flipStalePendingToFailed was stamping a state-description string onto
qb_sync_logs.error_message. SyncService.intiateSync reads that column
when reporting to Sentry on the final retry, so the placeholder was
being reported as if it were the real exception — misleading on-call.
Leave errorMessage untouched on the flip so the first retry that throws
populates it with the real reason via updateFailedSyncLog.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 11, 2026

OUT-3709

@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickbooks-sync Building Building May 11, 2026 1:25pm
quickbooks-sync (dev) Ready Ready Preview, Comment May 11, 2026 1:25pm

Request Review

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 11, 2026

Greptile Summary

This PR removes the hardcoded errorMessage placeholder ('Stale PENDING claim — worker did not finalise in time') from the flipStalePendingToFailed bulk update in SyncLogService. Because SyncService#intiateSync reads currentLog.errorMessage when reporting to Sentry on the final retry, the placeholder was surfacing as the apparent root cause, masking the real exception.

  • The one-line deletion leaves errorMessage as NULL on freshly-flipped rows; the first retry that actually throws will populate it via updateFailedSyncLog, and the Sentry report will carry the genuine reason.
  • The PR author notes that "silent early-return" paths in processInvoiceDeleted/processInvoiceVoided may now surface null in Sentry instead of the placeholder, which is acknowledged as a follow-up item.

Confidence Score: 5/5

Safe to merge — a single-line deletion that removes a misleading placeholder; no logic paths are altered and the database column already accepts NULL.

The change is a targeted one-line removal with no new code paths introduced. Flipped rows will carry NULL for errorMessage until a real retry exception writes the genuine reason, which is strictly more informative than the old placeholder. The PR author has correctly identified and scoped the residual gap (silent early-return paths) as a separate follow-up.

No files require special attention.

Important Files Changed

Filename Overview
src/app/api/quickbooks/syncLog/syncLog.service.ts Removes the misleading errorMessage placeholder from the flipStalePendingToFailed bulk update, so flipped rows carry null until a real exception populates the field on retry.

Sequence Diagram

sequenceDiagram
    participant Cron as Cron / syncFailedRecords
    participant SLS as SyncLogService
    participant DB as qb_sync_logs
    participant SS as SyncService#intiateSync
    participant Sentry

    Cron->>SLS: flipStalePendingToFailed()
    SLS->>DB: "UPDATE SET status=FAILED, category=OTHERS"
    Note over DB: errorMessage = NULL (placeholder removed)

    Cron->>SS: retry stale row
    alt retry throws real error
        SS->>DB: updateFailedSyncLog(realError)
        Note over DB: errorMessage = real exception
        SS->>Sentry: "captureMessage(errorMessage = real exception)"
    else retry succeeds
        SS->>DB: "status = SUCCESS"
    end
Loading

Reviews (1): Last reviewed commit: "fix(OUT-3709): drop placeholder errorMes..." | Re-trigger Greptile

@SandipBajracharya SandipBajracharya changed the title fix(OUT-3709): drop placeholder errorMessage on stale PENDING flip OUT-3709: drop placeholder errorMessage on stale PENDING flip May 12, 2026
@SandipBajracharya SandipBajracharya merged commit 4018417 into master May 12, 2026
5 checks passed
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.

1 participant