• Rose ( umbraroze@slrpnk.net ) 
    link
    fedilink
    arrow-up
    22
    ·
    1 year ago

    Aaagh! Getting some random old person flashbacks.

    Kids. I r-remember a day… You won’t believe this… I got a 404 error page… It was otherwise a normal 404 page with a normal message on it, but it had a giant ad on it… like “while you’re here, how about you buy this stuff”… It was hell… You’ve got no idea how lucky you kids are with uBlock…

  • Yep, I’ve got one of these at work now. Technically, 200 can make sense here if you’re using HTTP as RPC transport, as the server relayed the request to its handler and returned the outcome, but damn if it’s not annoying to actually process the response.

    I’ve also seen a lot of devs tie themselves into knots trying to map various execution types to the “semantically correct” HTTP code, but the thing is the abstraction of HTTP is not based around RPC and it’s ultimately a pretty weird fit that we’ve somehow come to view as normal.

  • whoisearth ( whoisearth@lemmy.ca ) 
    link
    fedilink
    arrow-up
    17
    ·
    1 year ago

    Fun story close to a decade ago we were attempting to upgrade our batch scheduler called Tidal to version 6x which had a RESTful API.

    One of the reasons we dropped the product was because we were getting 200 status codes meanwhile the output was a java dump of an error message.

    They were adamant that this was an us problem, no matter how much I tried to explain to them with numerous links explaining to them that if something has a 200 status code that should mean things worked.

    They argued that the 200 meant we were hitting the API fine. We would have to write code to read the return for if it was a error or not. I still don’t think they understood how stupid they were, even all these years later.

      • Slotos ( Slotos@feddit.nl ) 
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        However you like, REST doesn’t dictate anything there. Just be consistent and use hypermedia.

        JSON APIs almost never follow REST because they almost never use JSON as hypertext. Worse, no complete stable hypertext JSON standard exists. There’s JSON-HAL, but it lacks a way to represent resource templates (think HTML’s <form>).

        Therefore, with JSON APIs ignoring one of the most basic idea behind REST, why would anyone expect them to follow another idea of REST - consistency?

        REST is a deceptively simple concept. Any time you build an HTML website a human can navigate without consulting documentation, you’re doing it better than vast majority of swagger documented corporate APIs.

      • tempest ( tempest@lemmy.ca ) 
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        The argument probably goes something like " if you adhere strictly to REST the error codes are all you need" and then metadata can be sent in response headers.

        • how should a REST API respond to the client sending a URL the ends in a string instead of a numeric ID? like api.social/users/ceeforayteen instead of api.socail/users/11037

          • locuester ( locuester@lemmy.zip ) 
            link
            fedilink
            English
            arrow-up
            4
            ·
            1 year ago

            I would do a 400 (Bad Request). Then, with varying amounts of detail depending on the scale of the project and the framework capability, the response body would be something like: { “error”:true, “reason”: “validation”, “detail”: “user id should be numeric” }

              • locuester ( locuester@lemmy.zip ) 
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                1 year ago

                A RESTful service is (usually as of today) a JSON API. They aren’t mutually exclusive things.

                There’s no black and white definition there.

                However, when someone is creating a RESTful service, they’re stating that they’ll be paying mind to HTTP Verbs and status codes as a fundamental part of their design.

                In the original image posted, that dev clearly wasn’t paying mind to the HTTP layer and as such a commenter called it just a “JSON API”, which is the catchall, ugly, Wild West, typical way of doing things (always return 200, errors are in the json).

                Once again tho, it’s not black and white. Others can and will disagree and want to be pedantic. I’ve been a professional dev for 35 years, devs love to argue abt this shit.

                • devs love to argue abt this shit

                  Devs and standards have a contentious relationship.

                  If I develop something, I obviously know what works best for me, so I don’t want to be constrained by some dumb standard. If someone else doesn’t follow them and it makes things harder for me, they’re a clueless fuckwit that shouldn’t be allowed near a computer ever again.

                  Yes, that’s a double standard: I don’t even have a standard when it comes to handling standards.

    • JackbyDev ( JackbyDev@programming.dev ) 
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 year ago

      I don’t wanna be pedantic but most things we call REST aren’t REST. The original definition of REST is what we typically call HATEOAS. So when you say JAON API almost always means not REST you need to qualify that.

  • Been having similar case with dev teams who have coded every error to be 500. User typed the wrong URL? 500. User tried to access a page without logging in? 500… Makes detecting real errors a pain

    • Blackmist ( Blackmist@feddit.uk ) 
      link
      fedilink
      English
      arrow-up
      6
      ·
      1 year ago

      And on the other side of this are JS devs that check for neither error response codes or error messages, and write an error into their own data as if it’s the result they were after.

      Always fun to see GET /orders/{error : “invalid branchID provided”} in your logs.

  • NotSteve_ ( NotSteve_@piefed.ca ) 
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    1 year ago

    Marketo my beloved the bane of my existence. Actually without a doubt the worst API I’ve ever worked with in my career. The response schemas are random and a 200 means nothing because it might also include a “success”: “false”". Our backend API is Python and we have strict typing rule but Marketo really makes that difficult