skip to content

In a Postman collection, how does an `auth` type of `noauth` differ from a `null` type during inheritance?

level: middleimportance: should knowfreq 42%

answer

  1. One is a decision, one is an absence
  2. The validity check accepts any string type
  3. A null type never satisfies the lookup
  4. Passing null to the setter deletes the property

basics

~20 s

The noauth type is a real string, so it satisfies the lookup, stops the parent walk, and leaves the request unsigned. A null type fails the validity check, so the walk continues and an ancestor's credentials still apply.

solid answer

~40 s

Both look like "no credentials here", but only one of them is a decision. `noauth` is a **declared type**: the SDK's validity check accepts any string, so a block of `{ "type": "noauth" }` satisfies the lookup, the parent walk **stops** at that level, and the request goes out unsigned because the runtime's `noauth` handler signs nothing. A `null` type — or an `"auth": null` member, or no `auth` at all — fails that check, so the level is **transparent**: the walk continues outward and the nearest ancestor that does declare a block still governs. The SDK's tests pin this exactly: a request with `{ type: null }`, inside a folder with `{ type: null }`, under a collection declaring basic auth, still resolves to the collection's basic block.

code

json · 15 lines
json
{
  "auth": { "type": "bearer", "bearer": [{ "key": "token", "value": "{{accessToken}}" }] },
  "item": [
    {
      "name": "opted out",
      "auth": { "type": "noauth" },
      "item": [{ "name": "ping", "request": "https://example.com/ping" }]
    },
    {
      "name": "still inherits",
      "auth": null,
      "item": [{ "name": "me", "request": "https://example.com/me" }]
    }
  ]
}

go deeper

for a junior

Be ready to state the difference in one line: noauth is an explicit choice that ends the search, while a null or missing block simply leaves the level silent and lets a parent's credentials through.

for a middle

Be ready to explain the mechanism — the lookup accepts any string type, so noauth qualifies and terminates the walk, whereas a null type fails the check and the walk continues to the next ancestor.

for a senior

Be ready to defend writing noauth explicitly on subtrees that must stay unauthenticated, and to describe how relying on absence instead breaks the day someone adds a root-level block.

for a principal

Be ready to weigh legibility against brevity. Argue whether a collection many people edit should force an explicit declaration at every folder, and what review signal that buys against the extra noise.

## Two ways to say "no credentials", only one of which means it When you want a request under an authenticated collection to go out with nothing attached, there are two things the file can say and they behave oppositely. One is an **opt-out**: `{ "type": "noauth" }`. The other is an **absence**: no `auth` member, an `"auth": null`, or a block whose `type` is `null`. The first stops inheritance; the second is invisible to it. Confusing them is the single most common way a request ends up signed when someone meant it not to be, or unsigned when they thought a parent covered it. ## Why noauth stops the walk The SDK's parent lookup applies one predicate at each level: the entity has a truthy `auth`, and `RequestAuth.isValidType(auth.type)` returns true. That check asks only that the type be a **string** that is not literally the word `type` — a guard against colliding with the type selector inside the block. `"noauth"` is a perfectly ordinary string, so it passes, and there is no special case anywhere in the resolver that treats it differently from a named scheme. The walk therefore terminates at that level and returns the `noauth` block as the winner. What happens next is on the **runtime**. It ships a `noauth` handler, so this is a resolved type with a real implementation rather than a hole. That handler's `sign` step returns without touching the request, and its checks pass unconditionally. The request is sent exactly as written. The important consequence for a reader of the file: the collection's or an outer folder's credentials are never even consulted, because resolution already finished. ## Why a null type does not A `null` type fails the string test, so the level does not qualify and the lookup moves on. The SDK reinforces this at construction time as well. Both the request and the folder constructors build an auth object only for a truthy definition, guarded by a comment that says an empty one "should not be created for falsy values **to allow inheritance from parent**". If a falsy `auth` produced an empty object, that object would pass the truthiness half of the predicate and silently sever inheritance — the exact bug the guard exists to prevent. | What the level declares | Qualifies for the lookup | Walk behaviour | Outcome for the request | | --- | --- | --- | --- | | `{ "type": "noauth" }` | yes | stops at this level | sent unsigned, deliberately | | `{ "type": null }` | no | continues outward | whatever an ancestor declares | | `"auth": null` | no | continues outward | whatever an ancestor declares | | no `auth` member | no | continues outward | whatever an ancestor declares | | a named scheme | yes | stops at this level | signed with that block | The format permits every row of that table at all three declaration sites: the collection, a folder and a request each write `auth` as `oneOf` a null value or an auth object, so a null there is valid input, not a malformed document. ## The same distinction from code The SDK's setter mirrors it. `Request.authorizeUsing(type, options)` — the same function that `ItemGroup.authorizeRequestsUsing` binds onto a folder or a collection — treats `null` as a **delete**: it removes the `auth` property outright and returns, before the type-validity check ever runs. Calling it with the string `noauth` takes the other branch and installs a block. So the two operations are: - `authorizeUsing(null)` — remove the declaration; the level becomes transparent again and inheritance from the parents resumes. - `authorizeUsing('noauth')` — install a declaration that says "stop here, sign nothing". Neither raises an error, and nothing in the file distinguishes them after the fact except whether an `auth` member is present. ## Which one to write When a subtree genuinely should not carry credentials — a health check, an unauthenticated discovery endpoint, a public search — declare `noauth` on the folder. That is a statement someone can read and review, and it survives the request being edited later. Relying on absence instead is fragile in the other direction: absence means "whatever my ancestors say", and the day a root-level block is added, every silent request under it starts signing without anyone touching those requests. The converse also matters when reading. Seeing no `auth` on a request tells you nothing about whether it authenticates. Seeing `noauth` tells you it does not, and tells you somebody decided that on purpose. That difference in **legibility** — not any difference on the wire, since both end unsigned in the end — is the real reason to prefer the explicit form.

  • Both a resolved noauth and an unresolved lookup send the request unsigned — do they take the same path through the runtime?
    No. With nothing resolved the runtime bails out before the authorization step, because it gates on a resolved auth carrying a `type`. With `noauth` resolved it proceeds, loads the `noauth` handler and calls its `sign`, which returns without touching the request. Same wire result, different code path.
  • Can a request override a folder's noauth by declaring its own scheme?
    Yes. Resolution starts at the request, so a request that declares a usable block never reaches the folder at all. The folder's `noauth` only governs requests inside it that declare nothing usable of their own — it is a fallback like any other declaration, not a lock on the subtree.

saying these in an interview costs you the question

  • Treats noauth and an absent auth block as interchangeable
  • Says noauth is ignored because it declares no attributes
  • Claims a null type severs inheritance the way noauth does
  • Thinks writing a null auth makes the collection file invalid
  • Believes a folder's noauth cannot be overridden by a request below it