-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
SetParamValues function throwing index out of range [0] with length 0 error #1492
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
Also facing the same issue here. MaxParams is not settable from an outside package, your tests are passing because in each test case you are manipulating the variable to have the correct array size at all times. This breaks the compatibility |
same issue. I believe 8d7f05e#diff-05a3aa0ab9e5687ff167e0ef3ae4c5a6R316 from this PR #1463 may be what is causing the problem |
yes indeed, maxParams is unsettable outside fo the package. |
I'm also experiencing this issue |
@noamt there's a way to fix this #1463 (comment). It worked like a charm. Thanks @dlowe |
@yenskillah I think the issue is not solved, the way of "fixing" this cannot be some trick... maxParamValues should be settable from outside or make the array dynamic. There's even a PR open to address this: #1498 |
i'm experiencing the same issue |
I agree that this is not solved. We have tests that depend on #1498 would be usable since we could at least manually set |
Maybe @dlowe can shed some light. I don't see why the array can't be dynamic... the max param requirement note was introduced by him. |
I did not add the behavior or logic behind The comment I added was copied from https://github.com/labstack/echo/blob/master/context.go#L628. As I said in #1463 (comment): I agree this isn't ideal, but I don't actually understand the point of |
Maybe @vishr can tell us something |
The author of the issue whose fix broke functionality saying he doesn't "actually understand the point of |
To clarify: What I don't understand is why maxParam is needed at all, in the context of the whole echo framework. Given that it exists, I'm certain that the previous behavior of Someone with a better understanding of the intention behind maxParam might be able to make a change to |
@vishr Could we reopen this issue to ensure it is not breaking current test code.
So maxParam should be initialized with a sane value (e.g. 128) for now. My preferred solution would be to have a sane maxParam value and have a dynamically extending array of pvalues up to maxParam in size. This would allow for existing code to continue to work, keep memory requirements of the context at bay and still allow to have a limit defined to avoid eating to much memory for malicious requests. Feedback from @vishr would be required here on his point of view. |
@vishr I agree this issue needs to be reopened. We can't use a trick to close the issue. Could we please reopen and solve this? |
i am facing the same issue... |
@likejehu I've worked around this issue with v4.1.14 and v4.1.15 by downgrading to v4.1.13 for now. |
thanks, I just started to learn programming in general, and work with golang and with this library in particular and I don’t understand very well what is happening and what to do in situation where I need to write unit tests. But im facing this issue and dont know can i crank some magic trick or do i need to wait until it gets fixed. |
I took the change to modify the code where the error is taking place and monkey patch it. I tried to pull request it, but It fails for some reason on other side I cannot find yet. labstack > echo > context.go
|
@eddwinpaz Whether the priority of this issue should be raised. Since there is no alternative solution, all unit tests for echo are reported to be wrong. Especially with travis, it is difficult to control the echo version. |
So we've still had no solution yet? |
Review started already for the PR#1535. Thanks @178inaba |
Currently not working, i think it's due to a bug described in: labstack/echo#1492 so i will wait for it to be merged. If it isn't i don't know :) But the issue is when i try to do SetParamValues
* Set maxParam with SetParamNames Fixes #1492 * Revert go.mod
Yay, 2 months and it's now finally sorted |
Issue Description
Hi,
I' currently encountering an issue when setting parameter values via SetParamValues function. This is frequently used by my test cases, hence, tests are all failing.
Checklist
Expected behaviour
Should be able to set parameter values via SetParamValues function
Actual behaviour
SetParamValues function throws runtime error: index out of range [0] with length 0
Steps to reproduce
It will show this test logs afterwards:
Working code to debug
handler.go
handler_test.go:
Version/commit
8d7f05e
The text was updated successfully, but these errors were encountered: