• NigelFrobisher@aussie.zone
    link
    fedilink
    arrow-up
    17
    ·
    11 hours ago

    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.

    • TomasEkeli@programming.dev
      link
      fedilink
      arrow-up
      14
      ·
      7 hours ago

      Then just return a 500 - Server error. Nice and obscure.

      The ability to separate “something wrong with what you sent” (4XX) and “something wrong on the server” (5XX) is very valuable in itself.

  • Rose@slrpnk.net
    link
    fedilink
    arrow-up
    21
    ·
    13 hours 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…

  • katy ✨@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    50
    ·
    20 hours ago

    error = true with no description or answer is basically ten years of searching stackoverflow and reddit threads for an answer.

    • porkloin@lemmy.world
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      13 hours ago

      That’s true, but for a good reason. GraphQL is transport agnostic, so using HTTP status to represent errors doesn’t make sense. HTTP is just a carrier for GraphQL, and the status code represents whether or not the HTTP part was successful.

      • Olap@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        10 hours ago

        If only that were true. They are intimately connected and to pretend otherwise is laughable to me

        • porkloin@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          2 hours ago

          What do you mean? You can literally run GraphQL without HTTP. This isn’t just a GraphQL-ism, gRPC also does it https://grpc.io/docs/guides/status-codes/

          I understand that most people use GraphQL over HTTP and that from a developer perspective you’d rather have HTTP status codes like every other REST API. To which I’d say, why don’t you just use REST instead?

          There are a bunch of legitimate reasons why a clean separation of transport layer and application layer makes sense - you just aren’t using them so it feels like an arbitrary frustration to you.

          Have you ever run an application like a golang REST API behind an envoy or nginx proxy or load balancer and gotten an HTTP status 500 back and wrongly assumed it was coming from your application/golang code, only to later find it was a problem at the proxy or load balancer? If so, you’ve experienced the misdirection of combining transport and application layer being forced to share a status field. This isn’t a trivial example - time is wasted every day by developers misdiagnosing errors originating from transport as application errors, and vice versa.

          You might not like it, but separating them IS smart design.

  • Slotos@feddit.nl
    link
    fedilink
    arrow-up
    18
    arrow-down
    2
    ·
    19 hours ago

    JSON API almost always means “not REST”. In other words, it works as intended.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      ·
      3 hours 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.

      • Slotos@feddit.nl
        link
        fedilink
        arrow-up
        3
        ·
        11 hours 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@lemmy.ca
        link
        fedilink
        arrow-up
        3
        ·
        16 hours 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.

        • Aatube@kbin.melroy.org
          link
          fedilink
          arrow-up
          3
          ·
          15 hours ago

          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@lemmy.zip
            link
            fedilink
            English
            arrow-up
            7
            ·
            15 hours 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” }

          • tempest@lemmy.ca
            link
            fedilink
            arrow-up
            2
            ·
            15 hours ago

            Depends on the verb and the application. If the string is valid 200, if it isn’t 400, 404.

  • NotSteve_@piefed.ca
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    16 hours 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

  • floo@retrolemmy.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    18 hours ago

    Either way, the webpage didn’t load. And fuck literally everyone involved for not explaining to me what I need to do to fix it.

  • ryathal@sh.itjust.works
    link
    fedilink
    arrow-up
    6
    arrow-down
    3
    ·
    19 hours ago

    I’d rather see this than actual rest or the more popular use the bits of rest that are convenient.

    • traceur201@piefed.social
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 hours ago

      Right? REST is the transport, if you bend it to convey general/application errors it’s probably going to get bent out of shape eventually in a way that’s hard to clean up

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      17 hours ago

      you’d rather have no responses following a standard rather than only some doing that? No, thanks.