fix(cql2-rewrite-links): preserve client filter from POST body#162
Open
nicolaracco wants to merge 1 commit intodevelopmentseed:mainfrom
Open
fix(cql2-rewrite-links): preserve client filter from POST body#162nicolaracco wants to merge 1 commit intodevelopmentseed:mainfrom
nicolaracco wants to merge 1 commit intodevelopmentseed:mainfrom
Conversation
Cql2RewriteLinksFilterMiddleware read the client's original filter only from request.query_params, which is empty for POST /search where the filter lives in the JSON body. With no original filter to restore, the middleware fell into the strip-from-body branch and popped both `filter` and `filter-lang` from every paginated next-link body. Clients following `next` silently lost their filter, broadening every page after the first. Capture the client's `filter` and `filter-lang` from the POST/PUT/PATCH request body for endpoints matching ^/search$ (kept in lock-step with Cql2ApplyFilterBodyMiddleware.search_body_endpoints), echo them back verbatim into next-link bodies, and replay the buffered bytes via a wrapped receive so inner middlewares still see the unmodified body. Existing GET-with-query-string behavior is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Cql2RewriteLinksFilterMiddlewarestripsfilterandfilter-langfrom the body of paginatednextlinks when the client originally sent the filter inside a POST/searchbody. Following thenextlink therefore loses the filter, broadening every page after the first.The middleware was reading the client's original filter only from
request.query_params, which is empty for POST search. With nothing to restore, it fell into the strip branch and popped the fields outright.Reproduction
next.body returned by the proxy:
vs the same call against the upstream STAC API directly, which returns:
Fix
Symmetric with the existing query-string read:
query_params.get("filter")no-ops when the key is missing), drain the request body, JSON-decode it, and capturebody["filter"]andbody["filter-lang"]using a sentinel so we can distinguish "client sent no filter" from "client sent some value".receivesoCql2ApplyFilterBodyMiddlewareand the upstream still see the unmodified body.link.body, prefer the captured client values over the existing query-string-derived behavior; fall back to the prior pop-when-stripping-only path otherwise.The query-string
hrefbranch is unchanged.