Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: node
error-handlingobservabilitycorrectnessdata-integrity
Fail loudly when a required lookup is unmapped instead of silently dropping the record
A missing map entry that later throws inside a swallowing wrapper drops the item with no signal; guard and log the unmapped case explicitly.
PR: vinify-backend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const groupId = map[key]; // undefined |
| 2 | groupId.toString(); // throws, swallowed by wrapper, record lost |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const groupId = map[key]; |
| 2 | if (groupId === undefined) { logger.warn(`unmapped ${key}`); continue; } |
Explanation (EN)
Objašnjenje (HR)