Nobody has started this yet — be first.
Business impact
Independent of the delete-cache-invalidation ticket (DELETE forgetting to invalidate a warm cache entry), there is a second, deeper problem: even once a cache entry naturally expires or the process restarts (Redis cache cold, e.g. after a deploy, a Redis restart, or simply the TTL lapsing), a deactivated link resolves again anyway -- straight from Postgres. A "deleted" link is not actually gone; it just goes quiet for a while and comes back. For anything security- or compliance-sensitive (a takedown, an expired promo, a leaked internal link someone asked to be removed), this means "delete" never really means delete.
Problem
short_url = ShortURL.query.filter_by(slug=slug).first() in the cache-miss branch of resolve_short_url has no is_active=True filter.
Current behavior
Compare this to get_url_metadata and delete_url, which do their own lookups by slug alone (fine, since they are meant to be able to see deactivated rows for admin purposes) -- but the public redirect path has no such excuse.
Expected behavior
A row with is_active=False never resolves via GET /<slug>, whether or not it has a cache entry.
Steps to reproduce
Why this matters
This bug and the delete-cache-invalidation ticket look similar (both let a deleted link keep resolving) but they are different failure modes with different fixes: one is about not clearing a cache entry that already exists, the other is about the DB fallback trusting a row it should not. Fixing only one of them still leaves a deleted link resolvable through the other path -- they need to be fixed independently, which is exactly why they are separate tickets with separate, decoupled tests (this one never even touches the cache; it hits a guaranteed-cold slug directly).
Suggested approach
Compare this query against the query the original, correct version of this endpoint used (see: any other .filter_by(slug=..., is_active=True)-style lookup elsewhere in the file, or think about what "deactivated" should mean for the one endpoint whose entire job is serving the public redirect).
Acceptance criteria
Verification
pytest practice_tickets/tests/test_ticket_09_resolve_is_active.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/resolve-ignores-is-activeFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/resolve-ignores-is-activeSubmit 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 indocker-entrypoint.shcurl -X POST http://localhost:5000/api/urls \
-H "Content-Type: application/json" \
-d '{"target_url": "https://anthropic.com", "custom_slug": "claude"}'
# -> {"slug": "claude", "short_url": "http://localhost:5000/claude", "expires_at": null}
curl -i http://localhost:5000/claude # 302 redirect, records a click
make seed # or: docker compose exec web flask seed-db
If something is already listening on 5432/6379 locally, uncomment POSTGRES_HOST_PORT / REDIS_HOST_PORT in .env to remap the host side — the app always talks to db/redis over the compose network regardless. Run production-style (gunicorn, no dev server, no bind mount) with docker compose -f docker-compose.prod.yml up --build. GET /healthz checks both Postgres and Redis connectivity.
You do not need Docker running at all to work the tickets — the test suite uses TestingConfig (SQLite in-memory via StaticPool) and fakeredis instead of a real Postgres/Redis, 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_01_base62_roundtrip.py -v # a single ticket
./practice_tickets/run_tickets.sh # all 20, clean pass/fail summary
./practice_tickets/run_tickets.sh 05 13 16 # just a few, by number
All 20 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/ (via make test) runs the project's own main suite — some ticket bugs (TICKET-05, 07, 08, 09, 14 among others) also break assertions in that suite, since they are real bugs in shared code paths; fixing the ticket fixes those too, not a separate task.
Level 1
Fix a bug
Read existing behaviour, correct it.