GithubHelp home page GithubHelp logo

Comments (10)

LeifW avatar LeifW commented on July 22, 2024

I'd like to see a 400 Bad Request: foo is not in a format valid for a SSN: xxx-xx-xxxx in response to this, ideally.

from rho.

bryce-anderson avatar bryce-anderson commented on July 22, 2024

Documentation is certainly a thing we can improve all around.
I think there is a case to be made for a situation like this but it requires a bit of work in the PathTree. In particular, the matchString method is responsible to checking/parsing the route. Right now it returns a HList of successful parameters on a successful match, or null. I think this could be replaced with a RouteResult[HList] without sacrificing performance and allowing the route to continue to 'fall through' while preserving the fact that one failed and perhaps returning a 400 Bad Request.

On the other hand, when I think of a route I think that a path should either match or not, and I'd preserve the 'Bad Request' for a query or headers based parameter. I'm willing to have strong opinions about it one way or the other?

from rho.

LeifW avatar LeifW commented on July 22, 2024

Maybe the 400 is more appropriate for improperly formatted query params, not routes that we've dictated must be parseable as a some kind of data type?

from rho.

bryce-anderson avatar bryce-anderson commented on July 22, 2024

@LeifW, that my knee jerk feeling, but I'm far from an expert.

As a counter example, I think a more traditional framework would offer up the strings and it would be up to the route to determine if they are valid or not, in which case they would probably return a 400.

Any thoughts?

from rho.

LeifW avatar LeifW commented on July 22, 2024

I asked around. "RESTfulness calls for a 404", since a non-404 response would imply the existence of a resource there. I think I see that behavior elsewhere. Maybe if you want better error messages on these kind of keys, have them as a query param, instead? :/
But, maybe we could still make the body of the 404 more descriptive: "close, but no cigar"?

from rho.

aryairani avatar aryairani commented on July 22, 2024

Maybe I'm relatively new to REST, I would love to see more references on what kinds of things should be path params vs query params -- but "query params are used when you want more detailed errors" doesn't scratch the itch for me :-)
My gut sort of says "query params are optional params", but I know that isn't quite right either.

Not sure if there'd be a general way to say "404 because this happened during parsing". And even if there were a way, I don't know if it would be a good idea in general. But maybe during development? But supporting multiple modes creates even more work!

from rho.

aryairani avatar aryairani commented on July 22, 2024

I just realized I don't care at all what the HTTP code is, I just wished for debugging clues.

from rho.

bryce-anderson avatar bryce-anderson commented on July 22, 2024

Maybe this is a good case for simply adding some debug logging during path evaluation?

from rho.

aryairani avatar aryairani commented on July 22, 2024

That could work. Are there already some logging facilities to plug into?

I mean, a partial solution could also just be "remember how path var parsing works, now that you know", but if there's an easy way to get warnings, why not.

from rho.

bryce-anderson avatar bryce-anderson commented on July 22, 2024

I don't believe the PathTree type has any logging in it yet. I don't see a reason not to add it. We've been using log4s which has been really nice.

from rho.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.