Nobody has started this yet — be first.
Business impact
If a user mistypes a city name when saving it (or wants to correct "NYC" to "New York"), the only option today is to delete the saved city and create a new one -- losing the original created_at ordering position in their list (List orders by id ASC, i.e. insertion order) for no reason other than the API not supporting a rename.
Problem
cities.Store supports Create, List, Delete -- there is no update/rename operation, and no PUT /cities/{id} route; calling it returns 405 Method Not Allowed.
Current behavior
PUT /cities/{id} returns 405 Method Not Allowed regardless of who owns the city, whether it exists, or what the request body contains.
Expected behavior
PUT /cities/{id} updates the name of a saved city owned by the caller, leaving its id and position in the list unchanged. A non-owner or nonexistent id gets 404. An empty name is rejected with 400, the same validation POST /cities already applies.
Steps to reproduce
curl -X POST http://localhost:8083/cities -H 'X-User-ID: alice' -d '{"name": "NYC"}' # -> {"id":1,...} curl -X PUT http://localhost:8083/cities/1 -H 'X-User-ID: alice' -d '{"name": "New York"}'
Why this matters
This mirrors the ownership-scoped single-row update pattern used elsewhere in this project's sibling repos (category/expense Update methods) but doesn't exist yet anywhere in this one -- a good chance to apply the same WHERE id = $1 AND user_id = $2 pattern already established for Delete in this very file, to an UPDATE instead of a DELETE.
Suggested approach
Add a Store.Update(ctx, userID, id, newName) (City, error) mirroring Delete's ownership-scoped WHERE clause and Create's name-trimming/empty-name validation; wire a PUT /cities/{id} handler and route.
Acceptance criteria
Verification
WD_TEST_DATABASE_URL=postgresql://... go test ./practicetickets/... -run TestTicket05 -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
$git checkout -b feat/city-renameFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin feat/city-renameSubmit 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 inweather_dashboarddbappmockweatherWEATHER_API_BASE_URL=https://api.openweathermap.orgWEATHER_API_KEYdocker-compose.prod.ymlRun the project's own test suite:
make test # go test ./...
make test-race # go test -race ./... (includes the concurrency/partial-failure test)
Work the tickets in PRACTICE_TICKETS.md (TICKET-01 through TICKET-10); each names one Go test in practicetickets/:
./practice_tickets_run.sh # all 10, pass/fail summary
go test ./practicetickets/... -run TestTicket01 -v # a single ticket
go test -race ./practicetickets/... -run TestTicket10 -v # ticket 10 needs -race to observe its bug
Tickets 03, 04, 05, and 06 touch the saved-cities Postgres store and need a reachable test database, set via WD_TEST_DATABASE_URL (defaults to postgres://postgres:postgres@localhost:5436/weather_dashboard_test if unset). Tickets 01, 02, 07, 08, 09, and 10 need no database at all.
Level 2
Implement a feature
Extend the system within its own patterns.