• darvit@lemmy.darvit.nl
      link
      fedilink
      arrow-up
      5
      ·
      2 days ago

      This looks so over-engineered. Most of the time you only need an error message. Make the message clear enough so that it can be shown to the end user.

      • TomasEkeli@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        1 day ago

        Why even use HTTP, when you can just send bytes directly over the physical network card, right?

        Because standards make it better for everyone. You’ve no idea when, who or in what context the error will happen or be received by.

        It takes so little to return ProblemDetails, and improves the experience of devs using your API so much. Just do it. Stop thinking up edge cases and faffing about with excuses. Do it.

        • jj4211@lemmy.world
          link
          fedilink
          arrow-up
          2
          arrow-down
          1
          ·
          22 hours ago

          I think the challenge is that it looks like a lot of other ‘standards’ I’ve seen: on one hand tediously specific yet on the other hand, so open ended as to largely defeat the point.

          Every problem must have a ‘type’. Ok, fine, so what are the semantics of the ‘problem type’? Well, nothing in particular, just has to be defined, but it might be nice if it’s a url telling a human about your own human thoughts on the type. Also, if you encounter multiple ‘errors’, you need to omit any that you arbitrarily fail to group into the same ‘type’ which shouldn’t be subjectively too vague either, so don’t think about making catch-all types so you don’t have to discard some of the errors.

          You can’t count on the members, and a problem type may arbitrarily ‘extend’ to completely rearrange those members into members of child objects instead, but that’s really all up to the backend to decide however they want to arrange it, with no prescribed standard for error bundling, but an example of how a backend could voluntarily implement such bundling as an implementer specific extension if they like, but again, don’t bundle errors that shouldn’t seem to be of a common type…

          Also I think it’s funny that they say do this in the name of being a good web citizen, but then say send this new mime type down, client’s Accept header value be damned.

          It purports to drive toward “machine-readable” problems but it seems like there’s not much actually actionable and the client has to in practical terms do a bunch of bespoke handling to deal with a backend that is still pretty much open to do whatever they like.

          It has a couple of reasonable seeming examples, but nothing that would make me think “Oh, you implement RFC 9457? Then I already have error handling code ready to go!”

          I’ve seen all sorts of complex errors generated by backends that have all sorts of features like this and more (error messages with parameterized string values, json pointers to specific problematic pieces of the client request. However people just want a human readable response to pass along. I could imagine the example ‘pointer’ being useful to map error details to a client maintained form, but that’s not even the ‘standard’, just a random example ‘extension’…

          • darvit@lemmy.darvit.nl
            link
            fedilink
            arrow-up
            2
            ·
            14 hours ago

            Exactly! This is why the server should just send a clear error message. 99% of the time the client just wants to show the error message to the end user, and not have to wrangle all kinds of normalized data into one.

            • jj4211@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              5 hours ago

              I wouldn’t even mind wrangling some normalized data, but it doesn’t seem very normalized in their examples.

              Their first example suggests “great, there’s a human appropriate title and detail, and maybe this standard will say you should at least have those and they should be ready for pass through to a human operator”, with extensions providing room for more sophisticated behavior.

              Then the second example, no more top level detail, now there’s an ‘errors’ array, and detail is under the children (which they don’t formally describe the concept of reparenting attributes, just incidentally showing it in an example of what an implementation could do with ‘extensions’). Well, at least I can still pass through the details if I find them and it will make sense right? “must be a positive integer”… Ok, nope, error information that requires the client to process a json pointer in order to manufacture some sort of actionable feedback. Again, this could be a neat optional feature, but a generic core client really has nothing they can bite into that generically applies to the standard.

              The cited RFC I think is close to some ideas but softens it by trying to be open ended. If it specified mandatory top level “detail” member that is reasonably directly informative to a human operator without further processing, great, I know exactly where to find it even if I don’t otherwise understand your problem type. Mandate that errors may be a collection under an ‘errors’ list, but otherwise identical to top level? Cool. Saying that here’s some recommended members, but they are all optional and the behavior is really up to you, and you can just freely change everything you want and call it ‘extensions’… Just not prescriptive enough despite the long words…

    • douglasg14b@lemmy.world
      link
      fedilink
      arrow-up
      3
      arrow-down
      3
      ·
      1 day ago

      Counter argument is that error codes and problem details can be used by attackers to reverse engineer and find exploitable parts of a system.

      Within reason anyways

        • ryannathans@aussie.zone
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          19 hours ago

          Successful web request, web server functioning fine, application functioning fine, but the application needs to tell the user they have done something wrong in-app.

          In my world for example there’s a piece of third party hardware I need to take a bunch of data from and deliver it to the user. One part of that data is telling the user there’s an error and they need to perform an IRL interaction with it to fix something, but the rest of the data and images in the payload are good