Nobody has started this yet — be first.
Business impact
Any route that uses both strip_prefix and add_prefix together (a common combination -- "drop our external /api/v1 prefix and route into the upstream's own /v2 namespace instead") sends every request to the wrong upstream path. Depending on the upstream, that is either a wave of 404s for a route that looks correctly configured, or -- worse -- silently hitting a different, unintended endpoint on the upstream if one happens to exist at the wrong path.
Problem
rewrite_path()'s docstring says the order is strip_prefix -> regex rewrite -> add_prefix. The code applies add_prefix first, then strip_prefix, then the regex rewrite -- the exact opposite order for the first two steps.
Current behavior
For a route with strip_prefix="/api" and add_prefix="/v2", a request for /api/widgets becomes /v2/api/widgets instead of , because is applied to the original path before runs, and 's check then silently finds nothing to strip.
Expected behavior
For a route with strip_prefix="/api" and add_prefix="/v2", a request for /api/widgets becomes upstream path /v2/widgets -- strip the external prefix first, then add the internal one.
Steps to reproduce
Why this matters
Because add_prefix runs first, the subsequent strip_prefix check silently no-ops instead of failing loudly -- the path just ends up wrong, with no error anywhere to point at the cause. Routes using only one of the two options never exercise the interaction at all, which is exactly why this kind of ordering bug survives: strip_prefix alone and add_prefix alone both still work fine.
Suggested approach
Compare the order of the three if blocks in rewrite_path() against the order stated in the docstring immediately above the function. One of them is out of place.
Acceptance criteria
Verification
pytest practice_tickets/tests/test_ticket_06_transform_prefix_order.py -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b fix/transform-prefix-orderFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/transform-prefix-orderSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign in/v2/widgetsadd_prefixstrip_prefixstrip_prefixpath.startswith(config.strip_prefix)http://localhost:8080fast_echo/echo/.../large/{size_mb}slow_upstream/delay/{s}/flaky/always-downroutes.yamlcurl localhost:8080/healthzcurl localhost:8080/readyz/admin/*Authorization: Bearer <GATEWAY_ADMIN_TOKEN>You do not need Docker running at all to work the tickets — the test suite fakes Redis with fakeredis (plus lupa for real Lua-script support), so everything runs against a plain virtualenv:
python3 -m venv .venv && .venv/bin/pip install -r requirements-dev.txt
.venv/bin/pytest practice_tickets/tests/test_ticket_09_breaker_threshold_off_by_one.py -v # a single ticket
./practice_tickets/run_tickets.sh # all 15, clean pass/fail summary
./practice_tickets/run_tickets.sh 06 09 15 # just a few, by number
All 15 tests fail at the start; as you fix each ticket in app/, its test (and only its test) should flip to passing. .venv/bin/pytest tests/ runs the project's own main suite — as of writing it shows 8 pre-existing failures caused by ticket bugs 02, 04, 06, and 09; fixing those tickets fixes those failures too, not a separate task.
Level 1
Fix a bug
Read existing behaviour, correct it.