route:unmatched is the one terminal request event that carries no route, so the only subject a consumer can reach is name — and name is the concrete, caller-controlled path.
What happens
src/http/core.ts:297:
bus.emit('route:unmatched',{name:`${req.method}${path}`,// the path that arrived
method: req.method,requestId: req.requestId,traceId: req.traceId,});
No route, no status. Compare request:end, which carries route: trace.route — undefined for an unmatched request, so that one is no help either.
Why it matters
The cardinality doctrine is written into the codebase and it is right. Correlation's doc comment says it plainly:
a metrics consumer that labels a counter with a concrete path gets one label per distinct URL, and unbounded label cardinality takes down the metrics backend rather than the application. Handing anyone that shape by default would be the framework's fault.
That reasoning applies hardest to exactly this event. A matched route's path is bounded by the route table; an unmatched path is bounded by nothing at all. A scanner walking /aaa, /aab, /aac … is a memory leak with a metrics backend attached — and for this event, the concrete path is the only field a consumer is given.
The framework does not create the trap knowingly; it just leaves the one field that avoids it empty precisely where it matters most.
Scope
Deliberately small — this is a field, not a design:
Carry a bounded marker, e.g. route: '<unmatched>', on route:unmatched and on the request:end that follows it. It reads as a pattern, aggregates as one series, and needs no consumer to invent a fallback that some consumers will get wrong.
If that overloads route (it is documented as "the matched pattern", and nothing matched), an explicit matched: false works too. Either beats an empty field.
Either way, say in the doc comment that name is caller-controlled and must not be used as a metric label. request:start has the same property, but it is not a terminal event anyone counts.
Related
Found while writing metrics.plugin.ts for the green-desk demo. It collapses everything unmatched into a single <unmatched> bucket — the right behaviour, arrived at by reading src/http/core.ts, not by reading the payload type.
`route:unmatched` is the one terminal request event that carries no `route`, so the only subject a consumer can reach is `name` — and `name` is the concrete, caller-controlled path.
## What happens
`src/http/core.ts:297`:
```ts
bus.emit('route:unmatched', {
name: `${req.method} ${path}`, // the path that arrived
method: req.method,
requestId: req.requestId,
traceId: req.traceId,
});
```
No `route`, no `status`. Compare `request:end`, which carries `route: trace.route` — `undefined` for an unmatched request, so that one is no help either.
## Why it matters
The cardinality doctrine is written into the codebase and it is right. `Correlation`'s doc comment says it plainly:
> a metrics consumer that labels a counter with a concrete path gets one label per distinct URL, and unbounded label cardinality takes down the metrics backend rather than the application. Handing anyone that shape by default would be the framework's fault.
That reasoning applies hardest to exactly this event. A matched route's path is bounded by the route table; an **unmatched** path is bounded by nothing at all. A scanner walking `/aaa`, `/aab`, `/aac` … is a memory leak with a metrics backend attached — and for this event, the concrete path is the only field a consumer is given.
The framework does not create the trap knowingly; it just leaves the one field that avoids it empty precisely where it matters most.
## Scope
Deliberately small — this is a field, not a design:
- Carry a bounded marker, e.g. `route: '<unmatched>'`, on `route:unmatched` and on the `request:end` that follows it. It reads as a pattern, aggregates as one series, and needs no consumer to invent a fallback that some consumers will get wrong.
- If that overloads `route` (it is documented as "the matched pattern", and nothing matched), an explicit `matched: false` works too. Either beats an empty field.
- Either way, say in the doc comment that `name` is caller-controlled and must not be used as a metric label. `request:start` has the same property, but it is not a terminal event anyone counts.
## Related
Found while writing `metrics.plugin.ts` for the `green-desk` demo. It collapses everything unmatched into a single `<unmatched>` bucket — the right behaviour, arrived at by reading `src/http/core.ts`, not by reading the payload type.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
route:unmatchedis the one terminal request event that carries noroute, so the only subject a consumer can reach isname— andnameis the concrete, caller-controlled path.What happens
src/http/core.ts:297:No
route, nostatus. Comparerequest:end, which carriesroute: trace.route—undefinedfor an unmatched request, so that one is no help either.Why it matters
The cardinality doctrine is written into the codebase and it is right.
Correlation's doc comment says it plainly:That reasoning applies hardest to exactly this event. A matched route's path is bounded by the route table; an unmatched path is bounded by nothing at all. A scanner walking
/aaa,/aab,/aac… is a memory leak with a metrics backend attached — and for this event, the concrete path is the only field a consumer is given.The framework does not create the trap knowingly; it just leaves the one field that avoids it empty precisely where it matters most.
Scope
Deliberately small — this is a field, not a design:
route: '<unmatched>', onroute:unmatchedand on therequest:endthat follows it. It reads as a pattern, aggregates as one series, and needs no consumer to invent a fallback that some consumers will get wrong.route(it is documented as "the matched pattern", and nothing matched), an explicitmatched: falseworks too. Either beats an empty field.nameis caller-controlled and must not be used as a metric label.request:starthas the same property, but it is not a terminal event anyone counts.Related
Found while writing
metrics.plugin.tsfor thegreen-deskdemo. It collapses everything unmatched into a single<unmatched>bucket — the right behaviour, arrived at by readingsrc/http/core.ts, not by reading the payload type.