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
apidata-modellinghttpdocumentation
Confirm whether an API merges or replaces before sending a partial payload
Before calling an endpoint that mutates a resource, verify against its documentation whether it merges (patches) or fully replaces attributes, so you do not unintentionally wipe fields by sending a partial body.
PR: abcn-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | // unsure if this PUT/POST replaces all attributes or merges — sends partial body |
| 2 | await apiRequest({ method: 'POST', path: `/users/${userId}/attributes`, body: { phone } }); |
| 3 | // if the endpoint replaces, every other attribute is now lost |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // docs confirm this endpoint MERGES the provided attributes; partial body is safe |
| 2 | // (a replace endpoint would require sending the full attribute set) |
| 3 | await apiRequest({ method: 'PATCH', path: `/users/${userId}/attributes`, body: { phone } }); |
Explanation (EN)
Objašnjenje (HR)