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
authheaderscorrectnesserror-handling
Don't substitute an empty string for a missing auth token
If a required token is absent, handle that case explicitly rather than sending an empty-string header that silently produces a bad request.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codejavascript
| 1 | fetch(url, { headers: { 'mws-token': mwsToken ?? '' } }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | if (!mwsToken) { |
| 2 | return res.status(401).json({ message: 'Missing token' }); |
| 3 | } |
| 4 | fetch(url, { headers: { 'mws-token': mwsToken } }); |
Explanation (EN)
Objašnjenje (HR)