Nobody has started this yet — be first.
Business impact
A client that sends a request with a typo'd or made-up field name (e.g. "archivd": true, or an entirely unsupported field like "folder": "reading-list" that they assumed this API supports) gets a 201 Created with that field silently dropped, instead of a 400 telling them the request wasn't understood as intended. The client walks away believing their request succeeded exactly as sent -- when part of it was silently ignored -- which is a nasty class of bug to debug from the client side, since nothing on their end looks wrong.
Problem
POST /bookmarks's JSON decoder no longer rejects unknown fields -- any extra, unrecognized field in the request body is silently ignored rather than causing a 400.
Current behavior
POST /bookmarks with an extra field like "folder":"reading-list" returns 201, and the extra field simply doesn't appear anywhere in the stored/returned bookmark.
Expected behavior
A request body containing any field not in CreateRequest (url, title, tags) is rejected with 400 and a clear JSON error body, exactly like a missing required field is today.
Steps to reproduce
curl -s -X POST http://localhost:8081/bookmarks -H 'Content-Type: application/json'
-d '{"url":"https://example.com","title":"Test","folder":"reading-list"}'
Why this matters
encoding/json's decoder is permissive by default (it ignores fields with no matching struct field) -- the project opts into strict rejection via Decoder.DisallowUnknownFields(), and that call is what's missing here. It's a single removed line with no compile-time signal that anything changed.
Suggested approach
Compare create's JSON decoding setup against update's (a few lines below in the same file) -- one of the two still has the strict-decoding call the other lost.
Acceptance criteria
Verification
go test ./practicetickets/... -run TestTicket08 -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 fix/unknown-fields-silently-acceptedFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/unknown-fields-silently-acceptedSubmit 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 inmigrations/0001_init.sqlcurl http://localhost:8081/healthz
# {"status":"ok"}
To run without Docker, point the DB_* env vars from .env.example at a reachable Postgres and run go run ./cmd/server -- it applies the same migrations on startup.
The project's own test suite (go test ./...) is an integration suite against a real Postgres; it looks for one via BM_TEST_DB_HOST/BM_TEST_DB_PORT/BM_TEST_DB_USER/BM_TEST_DB_PASSWORD/BM_TEST_DB_NAME (defaults point at localhost:15433, database bookmarks_test) and skips cleanly rather than failing if that database is unreachable:
docker run -d --name bm_test_pg -e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=bookmarks_test -p 15433:5432 postgres:16-alpine
Work the tickets in PRACTICE_TICKETS.md (TICKET-01 through TICKET-10, all in one file, ordered easy -> hard); each names one Go test under practicetickets/:
go test ./practicetickets/... -run TestTicket01 -v # a single ticket
./practice_tickets_run.sh # all 10, clean pass/fail summary table
Level 1
Fix a bug
Read existing behaviour, correct it.