cm0002@lemmy.world to Programmer Humor@programming.dev · 7 days agoYes, But...lemmy.mlimagemessage-square79fedilinkarrow-up1758arrow-down19
arrow-up1749arrow-down1imageYes, But...lemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 7 days agomessage-square79fedilink
minus-squareMak'@pawb.sociallinkfedilinkEnglisharrow-up28arrow-down2·7 days ago …HTTP is a high level application protocol and its errors are supposed to be around access to resources… I’ve had fellow developers fight me on this point, in much the same way as your parent post. “If you return a 404 for a record not found, how will I know I have the right endpoint?” You’ll know you have the right endpoint because I advertised it—in Open API, in docs, etc. “But, if /users/123 returns a 404, does that mean that the endpoint can’t be found or the record can’t be found?” Doesn’t matter. That resource doesn’t exist. So, act appropriately.
minus-squareboonhet@lemm.eelinkfedilinkarrow-up9·7 days agoStandardize a response body across your APIs that specifies the cause of the non-2xx response. Have an enum per API/service for causes. Include them in the API doc. If anyone still doesn’t get it, quietly dispose of them at your friend’s pig farm.
minus-squareTakumidesh@lemmy.worldlinkfedilinkarrow-up4·6 days agoIt’s not like you can’t return a body with the 404 that specifies that the user itself is not found versus the ending being wrong.
I’ve had fellow developers fight me on this point, in much the same way as your parent post.
“If you return a 404 for a record not found, how will I know I have the right endpoint?”
You’ll know you have the right endpoint because I advertised it—in Open API, in docs, etc.
“But, if
/users/123
returns a 404, does that mean that the endpoint can’t be found or the record can’t be found?”Doesn’t matter. That resource doesn’t exist. So, act appropriately.
Standardize a response body across your APIs that specifies the cause of the non-2xx response. Have an enum per API/service for causes. Include them in the API doc.
If anyone still doesn’t get it, quietly dispose of them at your friend’s pig farm.
It’s not like you can’t return a body with the 404 that specifies that the user itself is not found versus the ending being wrong.