• The_Decryptor@aussie.zone
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 day ago

    Ehh, that really feel like “But other people do it wrong too” to me, half the 4xx error codes are application layer errors for example (404 ain’t a transport layer error, neither is 403, 415, 422 or 451)

    It also complicates actually processing the request as you’ve got to duplicate error handling between “request failed” and “request succeeded but actually failed”. My local cinema actually hits that error where their web frontend expects the backend to return errors, but the backend lies and says everything was successful, and then certain things break in the UI.

    • luciferofastora@feddit.org
      link
      fedilink
      arrow-up
      2
      ·
      18 hours ago

      frontend expects the backend to return errors, but the backend lies and says everything was successful, and then certain things break in the UI

      That’s a double failure then: not only does the backend do it wrong, the frontend devs don’t even know it. If they’d agreed on one way of handling it, they’d still be able to work it out. But if the devs don’t even communicate their standards with each other and the frontend devs obviously don’t know about the problem…

      • The_Decryptor@aussie.zone
        link
        fedilink
        English
        arrow-up
        2
        ·
        10 hours ago

        Yep, their frontend used a shared caller that would return the parsed JSON response if the request was successful, and error otherwise. And then the code that called it would use the returned object directly.

        So I assume that most of the backend did actually surface error codes via the HTTP layer, it was just this one endpoint that didn’t (Which then broke the client side code when it tried to access non-existent properties of the response object), because otherwise basic testing would have caught it.

        That’s also another reason to use the HTTP codes, by storing the error in the response body you now need extra code between the function doing the API call and the function handling a successful result, to examine the body to see if there was actually an error, all based on an ad-hoc per-endpoint format.

        • luciferofastora@feddit.org
          link
          fedilink
          arrow-up
          1
          ·
          5 hours ago

          So I assume that most of the backend did actually surface error codes via the HTTP layer, it was just this one endpoint that didn’t

          How is this getting even worse still? Why would a single endpoint work differently? That suggests they have standards, just one arsehole decided to shit on it and the rest didn’t vet their code enough to catch the issue.

          otherwise basic testing would have caught it

          I worked QA in a small dev team for two years. You might be surprised how uncomfortable you can make some developers within five minutes of “basic testing”. By the time I left, the team lead loved me as much as some of the devs must have hated me.