-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Bind causes panic or false-positive error if path has :param #1495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Tested again with v4.1.16: same results. Someone emailed me and said this isn't a bug (I don't have the email off hand), but since there's been no reply to this issue, I still consider it a bug. The server should definitely not panic (first case with single var), and it always worked before in the second case (slice of vars). |
Do not throw an error when binding to a slice, if binding occurs on path- or query-parameters => data is very likely to be found in the body, which will be bound later Should fix labstack#1356, labstack#1448, labstack#1495 (second case), labstack#1565
If your struct has a field which matches a url :param such as It caught me by surprise, and if you're not aware of this, there's a lot of potential for unwanted side-effects. Given this, for your scenario I can't imagine how it would apply imo the mega Bind implementation is neat, but somewhat overloaded, and maybe it's preferable to specify the type of request content wanted to bind, instead of choosing all the things else roll your own binder. Perhaps composable bind implementations? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Do not throw an error when binding to a slice, if binding occurs on path- or query-parameters => data is very likely to be found in the body, which will be bound later Should fix labstack#1356, labstack#1448, labstack#1495 (second case), labstack#1565
Issue Description
In v4.1.14 and v4.1.16, Bind is still broken (similar to issues #1448 and #1356) when the path has a
:param
and the bind variable is not initialized. Without a path:param
, both work as expected.Checklist
Expected behaviour
Bind should work for both paths with params in the example code below, no panic or error.
Actual behaviour
Panic on bind to a single var.
False-positive error on bind to slice of vars.
Steps to reproduce
See working code below.
Working code to debug
For single var (
/one/:foo
):For a slice of vars (
/many/:foo
)Remove
:foo
param from both paths and both will work as expected.Version/commit
v4.1.14 and v4.1.16
The text was updated successfully, but these errors were encountered: