fix(OUT-3575): handle Intuit OAuth's new error format for auth errors#218
Merged
SandipBajracharya merged 3 commits intomasterfrom Apr 10, 2026
Merged
fix(OUT-3575): handle Intuit OAuth's new error format for auth errors#218SandipBajracharya merged 3 commits intomasterfrom
SandipBajracharya merged 3 commits intomasterfrom
Conversation
Intuit silently changed their OAuth error response from Axios-style
`{ response: { status, data } }` to `{ error, error_description, intuit_tid }`.
This caused refresh token expiry errors to go undetected, preventing
notification emails to IUs. Add isIntuitOAuthError type guard and
update all error handling paths (withErrorHandler, auth.service, error utils).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
priosshrsth
requested changes
Apr 10, 2026
Collaborator
priosshrsth
left a comment
There was a problem hiding this comment.
@SandipBajracharya Could you simplify the function to check intuit error?
…pRetry pRetry discards non-Error throws, so the raw Intuit OAuth plain object was being replaced with a generic TypeError before reaching our error handlers. Wrap in IntuitOAuthError extends Error with a fromRaw() factory method so the error fields survive the retry pipeline. Also fix branch ordering so isIntuitOAuthError is checked before instanceof Error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…oken Apply the same IntuitOAuthError.fromRaw() wrapping to all Intuit OAuth SDK calls so pRetry doesn't discard plain-object errors from any path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
{ response: { status, data } }to{ error, error_description, intuit_tid }. This caused refresh token expiry errors to go undetected, preventing notification emails to IUs.IntuitOAuthError extends Errorclass with afromRaw()factory method to wrap Intuit's plain-object errors into proper Error instances. This is necessary becausepRetrydiscards non-Error throws.isIntuitOAuthErrortype guard (nowinstanceofbased) and updated all error handling paths.OAuthErrorCodes.INVALID_GRANTconstant to replace magic string comparisons.Changes
src/app/api/core/exceptions/custom.tsIntuitOAuthErrorclass withfromRaw()factory +isIntuitOAuthErrorinstanceof guardsrc/app/api/core/utils/withErrorHandler.tsIntuitOAuthErrorbefore genericErrorbranch + Sentry capturesrc/app/api/quickbooks/auth/auth.service.tsisAxiosErrortoisIntuitOAuthError, use constant forinvalid_grantchecksrc/constant/intuitErrorCode.tsOAuthErrorCodeswithas constsrc/utils/error.tsIntuitOAuthErrorbefore genericErroringetMessageAndCodeFromErrorsrc/utils/intuit.tsIntuitOAuthError.fromRaw()in all SDK calls (_refreshAccessToken,_authorizeUri,_createToken)Key design decisions
IntuitOAuthError extends Error? —pRetrydiscards non-Error throws with a genericTypeError, losing all Intuit error fields. Wrapping in a proper Error subclass preserves them through the retry pipeline.fromRaw()factory? — Keeps plain-object shape detection in one place. Callers just dothrow IntuitOAuthError.fromRaw(error) ?? error.isIntuitOAuthErrorbeforeinstanceof Error? — SinceIntuitOAuthError extends Error, the genericinstanceof Errorbranch would catch it first, making our specific handler dead code.shouldRetryinwithRetry.tsonly retriesstatus === 429.IntuitOAuthErrorhas no status, so it fails fast. Network/rate-limit errors still retry normally.Test plan
turnOffSyncis called and IU notification email is sentinvalid_grantOAuth error (e.g.invalid_client) — verify error is caught and reported to Sentry🤖 Generated with Claude Code