fix: add ROOT_PATH_SKIP_PREFIXES to exempt sibling-service links from root_path rewriting 2#198
Conversation
… root_path rewriting On shared-host deployments (e.g. eoapi-k8s defaults: proxy at /stac, titiler at /raster, /vector, /browser on one hostname), STAC responses carry same-host links to sibling services. ProcessLinksMiddleware cannot distinguish these from its own links by netloc — with OVERRIDE_HOST=false the upstream generates its links with the request netloc too — so it prepends ROOT_PATH to them, producing broken links (/stac/raster/... 404). Add an opt-in ROOT_PATH_SKIP_PREFIXES setting: same-host links whose path matches a configured prefix (path-segment-aware) are left untouched. Unset (default) keeps behavior unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… prefix - add a regression test asserting upstream-host links are still rewritten even when their path matches a skip prefix (the setting describes sibling services on the proxy's public hostname) - raise on a bare '/' prefix instead of silently dropping it (it would otherwise read as 'skip everything' but do nothing) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @pantierra's task in 2m 57s —— View job Claude's Task List
✅ No blocking issues — safe to merge. Traced
No security issues (no new attack surface — this only narrows which links get a path prepended, never adds new redirection targets). Simplify (ponytail): none — the latest commit ("Love you, too, ponytail.") already extracted the duplicated inline 💰 Estimated review cost: $1.02 · 2m57s · 32 turns |
f383dbd to
0a13430
Compare
935f20c to
9b0361c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #198 +/- ##
==========================================
+ Coverage 89.42% 89.67% +0.25%
==========================================
Files 30 30
Lines 1314 1337 +23
Branches 176 182 +6
==========================================
+ Hits 1175 1199 +24
Misses 96 96
+ Partials 43 42 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alukach
left a comment
There was a problem hiding this comment.
Nice work @lhoupert & @pantierra!
🤖 I have created a release *beep* *boop* --- ## [1.2.0](v1.1.1...v1.2.0) (2026-07-23) ### Features * add optional prometheus metrics endpoint. ([#186](#186)) ([6825f23](6825f23)) ### Bug Fixes * add ROOT_PATH_SKIP_PREFIXES to exempt sibling-service links from root_path rewriting 2 ([#198](#198)) ([349986b](349986b)) * allow , delimited string in configuration ([#191](#191)) ([df530a2](df530a2)) * allow Any type for classInput ([#182](#182)) ([56aa3f5](56aa3f5)) * configurable upstream timeout. ([#174](#174)) ([533bac6](533bac6)) * **helm:** make health path take root path into account. ([#189](#189)) ([5236a0e](5236a0e)) * publish helm chart only on release ([#178](#178)) ([c89f650](c89f650)) * **tests:** fix flaky health-check retry test caused by global asyncio.sleep patch ([#193](#193)) ([fec33b6](fec33b6)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: ds-release-bot[bot] <116609932+ds-release-bot[bot]@users.noreply.github.com>
closes #196
🤖 Claude text below 🤖
On shared-host deployments (e.g. eoapi-k8s defaults: this proxy at
/stacwith titiler at/raster,/vector,/browseron the same hostname), STAC items carry same-host links to sibling services (rel=xyz,tilejson,viewer, ...).ProcessLinksMiddlewareprependsROOT_PATHto every same-host link, sohttps://host/raster/...is served ashttps://host/stac/raster/...→ 404. Netloc can't disambiguate these: withOVERRIDE_HOST=falsethe upstream honours forwarded headers and generates its own links with the request netloc too, and those must keep gettingROOT_PATH(pertest_transform_with_forwarded_headers).This adds an opt-in
ROOT_PATH_SKIP_PREFIXESsetting (comma-separated path prefixes, e.g./raster,/vector,/browser): same-host links whose path matches a configured prefix are left untouched. Matching is path-segment-aware (/rastermatches/rasterand/raster/..., not/rasterfoo); trailing slashes are normalized. Unset (the default) leaves behaviour byte-identical to today — all existing tests pass unchanged; regression tests and docs added.We hit this in production at EOPF-Explorer/platform-deploy#343 and currently run this guard as a patched image.
Author attestation
AI-assisted: implementation and tests drafted with Claude, reviewed by me, and validated against the full test suite (478 passed) and pre-commit hooks (ruff, isort, mypy).