fix(sync): surface error context on sync run failures#140
Open
Vswaroop04 wants to merge 1 commit into
Open
Conversation
…ai#139) When sync run fails, the result now includes a structured error object with message, httpStatus, and retryAfter — rather than an opaque status: "failed" with no diagnostic context. This lets agents and operators distinguish a 429 rate-limit from a 401 auth failure from a network error without parsing the message string. The runner attaches _httpStatus and _retryAfter from ApiError before re-throwing so the command layer can forward them. SyncRunError is introduced in types.ts so callers have a typed surface to match on. Human-readable output also prints the HTTP status and retry hint when present.
Member
|
@Vswaroop04 - Could you update the package.json version here? |
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.
Was looking around the codebase and noticed that when
sync runfails, the result comes back as{ status: "failed" }with just a flat error string — no HTTP status, no retry timing, nothing an agent or script can key off programmatically. This means a 429 rate-limit looks identical to a 401 auth failure, which makes automated retry logic a guessing game.The fix is minimal and follows the patterns already in the codebase. The runner's catch block already attaches
_recordsSyncedand_pagesProcessedto thrown errors so callers can report progress; I added_httpStatusand_retryAfteralongside those, pulling the values directly offApiError(which already carries them from the Retry-After header parser). ThesyncRunCommandcatch inindex.tsthen builds a structurederrorobject from those fields rather than a bare string. A newSyncRunErrorinterface intypes.tsgives callers a typed surface to match on — distinguishing 429 from 401 from a network failure without parsing the message.The human-readable output is also updated to print the HTTP status and retry hint when present, which helps during manual debugging.
Closes #139.