Skip to content
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

URL Path Parameter get bugged #1461

Closed
constantins2001 opened this issue Dec 16, 2019 · 11 comments
Closed

URL Path Parameter get bugged #1461

constantins2001 opened this issue Dec 16, 2019 · 11 comments
Labels

Comments

@constantins2001
Copy link

Issue Description

Context#Param(name string) doesn't work in certain constellations.

Checklist

  • [ X ] Dependencies installed
  • [ X ] No typos
  • [ X ] Searched existing issues and docs

Expected behaviour

The following code yields results for handler1 (using c.Param("page")) and for handler3 and handler4 (using c.Param("id"))

	mux.GET("path/:page", handler1)
	mux.POST("path", handler2)
	mux.PATCH("path/:id", handler3)
	mux.DELETE("path/:id", handler4)

Actual behaviour

The following code yields and empty string for handler3 and handler4 (using c.Param("id")).

	mux.GET("path/:page", handler1)
	mux.POST("path", handler2)
	mux.PATCH("path/:id", handler3)
	mux.DELETE("path/:id", handler4)

The following code yields and empty string for handler1 (using c.Param("page")).

	mux.POST("path", handler2)
	mux.PATCH("path/:id", handler3)
	mux.DELETE("path/:id", handler4)
        mux.GET("path/:page", handler1)

Steps to reproduce

func handler3(c echo.Context) error {
	idParam := c.Param("id")
        log.Println(idParam);
}

Working code to debug

See above

Version/commit

Latest (github.com/labstack/echo)

@constantins2001
Copy link
Author

After reading through this issue I found that that all parameter names for the same endpoint need to be the same (which was my temporary fix).
It would certainly be advisable to mention this in the docs

@infiz
Copy link

infiz commented Dec 24, 2019

I am seeing the same issue and having the workaround as @SaubereSache mentioned. However, it makes the code harder to maintain. It would be good if it can be fixed.

@nhapq
Copy link

nhapq commented Dec 27, 2019

Revert to version 4.1.5 fix the issue in our case.

echo/router.go

Line 302 in 5c7c87d

func (r *Router) Find(method, path string, c Context) {

@asahasrabuddhe
Copy link
Contributor

Refer #1467 I think your issue should be fixed starting from version 4.1.13

@constantins2001
Copy link
Author

Works, thanks for the fix :)

@constantins2001
Copy link
Author

Regression, broke again as of v4.1.16 (@asahasrabuddhe @vishr)

@stale
Copy link

stale bot commented Jun 12, 2020

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.

@stale stale bot added the wontfix label Jun 12, 2020
@stale stale bot closed this as completed Jun 20, 2020
@sm4ll-3gg
Copy link

Is it still actual?

@smoyer64
Copy link

We ran into this bug again using v4.1.16 on one of our projects. The tests that were added as part of the merge for #1467 only test the GET and POST verbs.

@yoshihiro-shu
Copy link

We'are facing this problem at v4.7.2.
how can i solve it?
if someone know how to solve it, could you tell me?

@aldas
Copy link
Contributor

aldas commented Nov 21, 2022

I think this problem was fixed with #2209 in v4.8.0. Related issues #1726 and #2201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants