feat(safePushData): detailed error reporting and result tracking - #4
Merged
metalwarrior665 merged 3 commits intoJul 27, 2026
Merged
Conversation
Each failing round now reports the set of offending field paths (with the AJV keyword) instead of just an item count, split into fields we repaired and fields that forced a drop. The give-up log lists the fields still failing. The set is intentionally not a per-item breakdown: one bad field usually appears on many items in a batch, and array indices collapse into `/tags/[]` for the same reason. The list is capped at 20 entries with the overflow counted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ek1iV9QVKioLZ3EiL4cPYc
…r logic BREAKING: the result shape now names what it holds — `pushed` -> `pushedCount`, `dropped` -> `droppedItems`, `attempts` -> `attemptCount`. `*Count` is a number, `*Items` is an array of objects. Whatever `pushFn` resolves to is handed back as `pushResult` (the successful call's value; absent when every item was dropped). `PushFn<T, R>` and `SafePushDataResult<T, R>` carry the type through. Logic fixes found while reviewing: - Hitting the attempt cap used to drop the *entire* remaining batch, including items the API never complained about — the exact data loss this wrapper exists to prevent. Now only the items still failing are dropped and the survivors get one final push of their own. - Sibling array elements were spliced front-to-back, so the second `/tags/N` path pointed at a shifted array: a valid element could be deleted while the invalid one stayed. Errors are now applied deepest- and highest-index-first. - A nested `required` deleted the whole parent object; it now gets the same placeholder treatment as a root-level one, at any depth. - An item whose errors are all unactionable (paths it doesn't have) was re-pushed unchanged until the cap, burning every attempt for the rest of the batch. It's dropped on the spot instead. - Give-up drops reported stale errors from an earlier round; the per-item errors are now reset each round, so they say why the item is failing *now*. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ek1iV9QVKioLZ3EiL4cPYc
Covers the gaps left by the previous round: additionalProperties at the root and nested, mixed error kinds in a single round, JSON Pointer escaping on placeholder paths, per-item state surviving a splice, dropped items reporting the caller's original, non-object items, invalid items the API sends no errors for, the salvage push (its pushResult, its rejection, non-schema errors from it), maxAttempts: 1, the guard's negative cases, log label formatting, and an end-to-end mixed batch. Each of the five logic fixes was mutation-checked: reverting the repair ordering, the pointer escaping, the salvage push, the no-progress drop, or the nested `required` handling makes the corresponding tests fail. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ek1iV9QVKioLZ3EiL4cPYc
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
This PR significantly improves the
safePushDatafunction with better error reporting, result tracking, and more informative logging. The changes make it easier to understand what happened during the push-and-repair process and provide access to the underlying push function's return value.Key Changes
pushed→pushedCount,dropped→droppedItems,attempts→attemptCount) and addedpushResultto capture what the push function resolved toRtoPushFnandSafePushDataResultto properly type the push function's return valueNotable Implementation Details
collectFieldIssues(),fieldIssueLabel(), andformatFields()for structured error reportingMAX_LOGGED_FIELDSconstant to prevent log flooding on pathological batchesNO_ERRORSconstant to reduce allocations for items with no errorsdropAt()helper centralizes position removal logic to keep parallel arrays in syncresult()helper ensures consistent return values across all exit pathshttps://claude.ai/code/session_01Ek1iV9QVKioLZ3EiL4cPYc