Skip to content

refactor(push): extract checkFileSize + pin the single-file-cap boundary#260

Merged
saadqbal merged 2 commits into
developfrom
refactor/push-size-cap-helper
Jul 14, 2026
Merged

refactor(push): extract checkFileSize + pin the single-file-cap boundary#260
saadqbal merged 2 commits into
developfrom
refactor/push-size-cap-helper

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Mutation testing (gremlins) surfaced a real gap: the size > MaxSingleFileBytes single-file-cap guard was duplicated at 4 sites (stream.go, tabular.go, text.go ×2), and its boundary was untestable at every oneMaxSingleFileBytes is a 500 MB const, so > vs >= could only be exercised with a 500 MB fixture. The CONDITIONALS_BOUNDARY mutant survived at all four.

Extract checkFileSize(relPath, size) so the guard lives in one place (behavior-identical — each caller still returns its own arity with the same sizeError), and add a unit test that asserts the boundary at exactly MaxSingleFileBytes with int64 values — no fixture.

Mutation-proven: flipping the helper > to >= fails TestCheckFileSize/exactly_at_cap_is_allowed.

Test plan

  • make ci green (build, vet, gofmt -s, go test -race, errcheck/ineffassign/misspell, schema-check).
  • Pure refactor + one new unit test; the 4 call sites keep identical behavior.

🤖 Generated with Claude Code


Note

Low Risk
Behavior-preserving refactor across push validation paths plus a new unit test; no API or cap value changes.

Overview
Centralizes the duplicated size > MaxSingleFileBytes guard into checkFileSize(relPath, size) in walk.go and routes discovery, tabular, text sidecar, and stream-time tar paths through it instead of inline checks. Customer-facing behavior stays the same: over-cap still returns the existing sizeError with the same file path and messaging.

Adds TestCheckFileSize to assert the cap boundary with int64 sizes only—especially that a file exactly at MaxSingleFileBytes is allowed (> not >=)—so mutation testing can catch a >= flip without a 500 MB fixture.

Reviewed by Cursor Bugbot for commit f0bb6c7. Bugbot is set up for automated code reviews on this repo. Configure here.

The `size > MaxSingleFileBytes` guard was duplicated at four sites (stream,
tabular, text ×2), and its boundary was untestable at every one: MaxSingleFileBytes
is a 500 MB const, so the `>` vs `>=` distinction could only be exercised with a
500 MB fixture. Mutation testing (gremlins) confirmed the CONDITIONALS_BOUNDARY
mutant survived at all four sites.

Extract checkFileSize(relPath, size) so the guard lives in one place — DRYing the
four call sites (behavior-identical: each still returns its own arity with the
same sizeError) — and add a unit test that asserts the boundary at exactly
MaxSingleFileBytes using int64 values, no fixture. Mutation-proven: flipping the
helper's `>` to `>=` fails TestCheckFileSize/exactly_at_cap_is_allowed.

make ci green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread internal/push/walk.go
… too

Bugbot (cli#260): the first pass extracted checkFileSize but Discover in walk.go
still inlined the same size > MaxSingleFileBytes / sizeError pattern for
labels.csv and images/ — leaving 2 boundary sites the extraction was meant to
kill (gremlins flagged walk.go:169/238) and making the 'exactly one place'
comment false. Route both through checkFileSize; now all 6 sites (image-layout,
stream, tabular, text) share the single tested guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f0bb6c7. Configure here.

@LukasWodka LukasWodka self-assigned this Jul 14, 2026

@saadqbal saadqbal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 All six call sites are faithful 1:1 extractions (same name + size args, same sizeError), and centralizing the guard finally makes the > vs >= boundary assertable at exactly the cap without a 500 MB fixture. Clean.

@saadqbal
saadqbal merged commit 91dded6 into develop Jul 14, 2026
18 checks passed
@saadqbal
saadqbal deleted the refactor/push-size-cap-helper branch July 14, 2026 08:56
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.

2 participants