Skip to content

fix: enforce local PUT conditions across tier transitions - #299

Open
perfloop[bot] wants to merge 5 commits into
mainfrom
perfloop-pr-open-zv39np5gjn
Open

perfloop[bot] wants to merge 5 commits into
mainfrom
perfloop-pr-open-zv39np5gjn

Conversation

@perfloop

@perfloop perfloop Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Larger conditional replacements now check the local object's preconditions before moving its body upstream. Tier selection no longer delegates a local ETag or existence check to an upstream copy that may not exist.

TestTieredLargePutLocalConditions fails without this change and passes with it.

TestTieredLargeConditionalPutContentEncoding fails without this change and passes with it.

  • Share the local store's precondition rules, including confirmed absence and retryable body-probe errors, with validated plain-object PUTs above the tier threshold.
  • Re-sign locally satisfied forwards as the caller, preserving signed-chunk authentication and checksum trailers. Join all content-encoding fields before stripping decoded AWS framing so other encodings survive separate field lines.
  • Carry the condition's metadata snapshot through upstream-marker publication rather than reading a newer token after the decision.

Upstream-tier conditions, unconditional transitions, and unvalidated forwarding keep their existing paths.

TestTieredLargePutLocalConditions in proxy/tiered_put_conditions_test.go checks create-only rejection without forwarding or changing the local object, and matching-ETag replacement through both forwarding flavors. TestTieredLargeConditionalPutContentEncoding checks separate encoding fields, exact gzip readback, GET/HEAD labels, and caller-header preservation. TestTieredLargeConditionalPutPreservesRacingLocalWrite gates a competing metadata write with CAS coordination enabled. The same file covers routing, read failures, authenticated streams, checksum rejection, body closing, and presigned uploads.

TestHeadersForForwardedSigning in proxy/chunk_verify_test.go covers encoding order, combined fields, and unchanged nonchunked headers. Re-signing tests in auth/validator_test.go compare signatures with the AWS SDK; auth/chunk_verifier_test.go checks trailer signatures against the original chunk chain.

Upstream writes and local metadata commits remain non-atomic. Racing-write protection retains the selected coordinator's guarantees; legacy coordination still has its existing write-vs-write check-then-store window. Transition frequency and deployed impact are unmeasured.

2 recorded checks pass with this change.

  • Auth, proxy, and HTTP handler tests
  • Go formatting and module consistency

Generated by Perfloop.


Note

Medium Risk
Changes tiered PUT routing, SigV4 re-signing, and streaming trailer verification—correctness-sensitive paths—but behavior is scoped to tiered conditional forwards with broad new tests.

Overview
Tiered mode now evaluates If-Match / If-None-Match against the local object (or confirmed absence) for validated plain-object PUTs—even when the replacement body is above cache.size_threshold and will be stored upstream. Failed checks return 412/404 without forwarding; successful checks strip the precondition headers and forward via a new forwardPutWithoutConditions path on both signing and transparent forwarders.

Shared checkPutConditions replaces duplicated logic in the local PUT handler. The tiered router loads prior metadata for any conditional plain PUT, sets localConditions when upstream must not see the client's ETags, and reuses the decision-time snapshot for upstream-marker publication.

Forwarding after local conditions uses preparePutWithoutConditions: decode or re-frame the body (verify signed chunks; for STREAMING-*-TRAILER, authenticate the trailer with new VerifyTrailer, then emit unsigned chunked wire with checksum trailers preserved). ValidatedRequest.Resign re-signs as the original caller (header or presigned query). headersForForwardedSigning joins all Content-Encoding field lines before stripping aws-chunked, so encodings like gzip on separate lines survive.

Docs (README, docs/tiered-mode.md) describe the new precondition and re-sign behavior. Large integration coverage lives in proxy/tiered_put_conditions_test.go.

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

Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous encoding-loss finding is fixed and no new blocking issue was found.

Summary

The PR checks local PUT conditions before forwarding larger replacements upstream, preserves caller authentication and checksum trailers, and carries the original metadata version through marker publication.

  • Large conditional PUTs check the prior object's tier before forwarding.
  • Forwarded uploads keep the caller's signature after TAG checks local conditions.

Reviews (2) · Last reviewed commit: "fix: preserve all content encoding field..." · Reviewed by Greptile

Comment thread proxy/conditional_put.go Resolved
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
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.

1 participant