In Postman, what happens to {{$timestamp}} if a variable literally named $timestamp exists in a run's scopes?
answer
- The generator is a fallback, not a reservation
- Defaults are consulted after held variables
- A same-named key silently wins
- No warning fires on the collision
basics
~20 sThe saved variable wins and the placeholder stops generating. Postman's dollar-prefixed generators are registered as substitution defaults consulted last, so a same-named variable is found first and {{$timestamp}} returns its stored value on every send, silently.
solid answer
~40 sThe generator is **shadowed**. The SDK registers `$guid`, `$timestamp`, `$isoTimestamp` and `$randomInt` as substitution *defaults*, and defaults are consulted **last** — substitution first asks the variables the run actually holds. A variable whose key is literally `$timestamp` therefore answers the name before the default is ever reached, so `{{$timestamp}}` resolves to that saved value and returns the same thing on every send. The failure mode is that it is completely silent: no error, no warning, no marker in the request. The token still looks dynamic in the request pane, the traffic just stops changing. That is why a dollar-prefixed key is worth treating as a reserved name and never used for a variable of your own.
code
json · 5 lines{
"key": "$guid",
"value": "fixed-id-for-debugging",
"type": "string"
}go deeper
Remember that a variable you save under the same name as a generator takes over from it, and that the placeholder then returns one unchanging value.
Explain the mechanism: the generators are registered as substitution defaults, defaults are consulted last, so any held variable of that name answers first.
Be ready to diagnose the silent version in a real run — no error fires, and the only symptom is downstream uniqueness or idempotency behaviour changing.
Argue the convention: treat dollar-prefixed keys as reserved by team agreement, since the tool enforces nothing and the failure surfaces far from its cause.
## The rule in one line A variable whose key matches a generator's name **wins**, and the generator never runs. Write `{{$timestamp}}` in a request while some scope holds a key literally spelled `$timestamp`, and the token resolves to that saved value — identical on every send, for as long as the key exists. ## Why *last* is the operative word The collection SDK registers its dollar-prefixed generators — `$guid`, `$timestamp`, `$isoTimestamp` and `$randomInt` — as **substitutor defaults**. A default, by construction, is what answers a name when nothing else did. Substitution therefore asks the variables the run genuinely holds first, and only falls through to the default set when the name went unanswered. Two consequences follow directly: - The generators are **not reserved**. Nothing stops you from creating a variable called `$guid`; the tool treats the dollar sign as an ordinary character in a key. - The generators are **not privileged**. They lose every collision, because losing a collision is exactly what being a default means. (Which of several scopes supplies the winning value, when more than one holds the key, is a separate resolution-order subject. For shadowing it does not matter — *any* scope answering the name is enough to keep the default from being reached.) ## Before and after the collision | Situation | What `{{$timestamp}}` resolves to | Changes per send? | |---|---|---| | No variable of that name anywhere | the generator's fresh clock reading | yes | | A variable keyed `$timestamp` exists | that variable's saved value | no | | That variable is later removed | back to the generator's reading | yes again | Note the third row: shadowing is not destructive. Delete or disable the offending key and the default becomes reachable again on the next send. Nothing about the generator was changed or consumed. ## How the collision happens by accident Almost nobody sets out to define `$guid`. The realistic paths are: 1. **Debugging residue.** Someone pinned a fixed identifier during a bug hunt by saving a key named after the generator, so every send used the same value — and then forgot to remove it. 2. **Copy-paste of a whole scope.** A shared environment or collection variable set is imported wholesale and quietly carries a dollar-prefixed key somebody else added. 3. **A script writing the name it read.** Code that captures a value and stores it back under the same spelling it substituted turns a generator into a frozen constant from that point on. ```json { "key": "$guid", "value": "fixed-id-for-debugging" } ``` That single saved pair is enough to stop every `{{$guid}}` in the collection from generating. ## The silence is the hazard There is no diagnostic. The request pane still shows a token that looks dynamic; the run reports no collision; nothing is logged. The only visible symptom is downstream and behavioural: - a uniqueness constraint on the server starts rejecting the second and later sends; - an idempotency key stops varying, so a payment or order endpoint keeps replaying the first result; - a clock reading intended to expire stays stuck at a value from an earlier session; - two iterations of a run produce byte-identical requests where the whole point was that they should not. ## Detecting and fixing it 1. Search every scope in play for a key beginning with a dollar sign. A dollar-prefixed key you did not deliberately create is the bug. 2. Confirm by sending twice and comparing the value that actually left — a value repeating exactly is the tell, since a real generator practically never repeats. 3. Remove or rename the offending key rather than renaming the token; the token spelling is the SDK's, and the key is yours to change. 4. Re-send and check the value moves again. ## Prevention, stated as a convention - Treat a leading dollar sign in a variable key as **reserved**, even though the tool does not enforce it. - If you deliberately want a frozen identifier, give it a name of your own — `fixedRequestId`, say — and reference that name. It makes the intent legible and leaves the generator available. - When reviewing a shared scope, scan the key list for dollar prefixes as a matter of routine; the cost of the check is seconds and the failure it prevents is silent. The underlying lesson generalises past this one tool: a *default* is a fallback, and any name you can also define yourself is a name you can accidentally take over.
- Does removing the shadowing variable restore the generator, or is something permanently broken?It restores it immediately. Shadowing is not destructive: the generator is still registered as a default and simply was not reached. Delete or disable the same-named key and the very next send falls through to the default again, producing fresh values with no other change required.
- Why does the tool allow a variable to be named after a generator at all?Because the dollar sign carries no special meaning in a key — it is an ordinary character. The generators gain their behaviour from being registered as defaults, not from owning a reserved namespace, so nothing validates or rejects a colliding key when you save one.
saying these in an interview costs you the question
- Says the generator always wins over a user variable
- Expects an error or warning when the names collide
- Believes dollar-prefixed names are reserved and cannot be defined
- Thinks the shadowing permanently disables the generator
- Claims the token is left literal when both could answer