fix(session): loosen remaining stored numeric schemas to tolerate legacy data#26622
Merged
kitlangton merged 1 commit intodevfrom May 10, 2026
Merged
fix(session): loosen remaining stored numeric schemas to tolerate legacy data#26622kitlangton merged 1 commit intodevfrom
kitlangton merged 1 commit intodevfrom
Conversation
…acy data Follow-up to #26620. The audit there flagged several other strict NonNegativeInt fields decoding stored DB JSON or external (git/HTTP) output. Same failure mode: one nonsensical legacy value (provider 4xx status reported as -1, git numstat dash-for-binary, etc.) makes the endpoint 400 with empty body and breaks the whole list response. Loosened to Schema.Finite (matching the pattern already used in Snapshot.FileDiff after #26574/#26579): - v2/session-event.ts: RetryError.statusCode, Retried.attempt - session/session.ts: Summary.{additions,deletions,files} - session/message-v2.ts: FilePartSourceText.{start,end} - project/vcs.ts: FileDiff/FileStatus.{additions,deletions} - snapshot/index.ts: FileDiff.{additions,deletions} These are statistics/measurements crossing the HTTP boundary, not invariants — negative values shouldn't crash the response. Direct measurements that genuinely can't be negative (character offsets, retry counters, ripgrep stats) keep NonNegativeInt.
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
Follow-up to #26620. The audit done after that PR flagged additional
NonNegativeIntfields decoding stored DB JSON or external (git / HTTP) output where the same failure mode applies: a single nonsensical value (provider returns-1forstatusCode, git numstat emits-for binary files, an old client wrote a sentinel) makes the response Schema encoding fail and the endpoint returns empty-body 400 — taking out the entire list response.The constraint was wrong, not the data: these fields are statistics/measurements crossing an HTTP boundary, not invariants. Loosening to
Schema.Finitematches the pattern already adopted forSnapshot.FileDiff.{file,patch,status}in #26574 / #26579.Changes
src/v2/session-event.tsRetryError.statusCode0/-1/non-intsrc/v2/session-event.tsRetried.attemptsrc/session/session.tsSummary.{additions,deletions,files}-. SiblingSnapshot.FileDiffwas already loosenedsrc/session/message-v2.tsFilePartSourceText.{start,end}-1for "unknown range"src/project/vcs.tsFileDiff/FileStatus.{additions,deletions}Snapshot.FileDifflooseningsrc/snapshot/index.tsFileDiff.{additions,deletions}Direct measurements that genuinely can't be negative (character offsets within a known buffer, ripgrep stats coming from a single tool we trust, retry counters we own) keep
NonNegativeInt.Verification
Test plan
/instance/vcs/diffand/sessionendpoints still return 200 with valid dataRelated
Snapshot.FileDiff