Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Distinguish malformed input from missing resources
Choose validation and missing-resource statuses by domain meaning, not solely by parameter location.
Bad example
| 1 | if (!isValidProfileId(body.profileId)) throw new NotFoundException(); |
Explanation (EN)
Treating malformed input as missing resource can mislead clients about how to correct the request.
Objašnjenje (HR)
Good example
| 1 | if (!isValidProfileId(body.profileId)) throw new BadRequestException("Invalid profile ID"); |
| 2 | const profile = await findAuthorizedProfile(body.profileId); |
| 3 | if (!profile) throw new NotFoundException(); |
Explanation (EN)
This endpoint uses 400 for invalid shape and 404 for an unavailable resource after its authorized lookup; other APIs may document a different policy.
Objašnjenje (HR)
Notes (EN)
Distinguish malformed input from a valid identifier for a missing resource, following the endpoint's documented error and information-disclosure policy.
Exceptions / Tradeoffs (EN)
Whether an ID came from path or body does not alone determine 400, 404 or 422. Authorization may intentionally conceal existence.