Lesson 2
Query Parameter Models
Understand repeated keys, empty values, flags, arrays, and framework differences.
Query strings look like simple key-value pairs, but different frameworks model them differently.
?tag=api&tag=json&draft=&preview
A parser might see:
tagas two valuesdraftas an empty stringpreviewas a flag or as an empty value
Repeated keys
Repeated keys are legal in a query string:
?tag=frontend&tag=backend
Some frameworks keep the last value. Some collect all values into an array. Some require a naming convention such as tag[].
Empty values and flags
These are not identical in every system:
?debug
?debug=
?debug=true
If the server treats presence as true, ?debug may be enough. If it expects a boolean string, it may need debug=true.
Ordering
For ordinary filtering, parameter order usually does not matter. For signatures and cache keys, order can matter a lot. Signed URLs often require a canonical order and exact percent-encoding.
Safer mental model
Do not assume that parsing and rebuilding a query is harmless. Decide how your application treats:
- Repeated keys
- Empty strings
- Missing values
- Array syntax
- Sorting
- Encoding of spaces and plus signs
Once those rules are explicit, URL bugs become much easier to reproduce.