Open mila-rodriguez-netapp opened 8 months ago
Hello @mila-rodriguez-netapp ,
Have you been able to reproduce this behavior in a clean environment without plugins? I just copy/pasted your example, added a default backend and I was unable to reproduce this behavior. Could you provide more input? The issue you refer to, does not panic in 2.5
{
"$schema": "https://www.krakend.io/schema/v3.json",
"version": 3,
"timeout": "30000ms",
"cache_ttl": "300s",
"port": 8080,
"name": "polariscloud",
"disable_keep_alives": true,
"host": ["http://localhost:8080"],
"debug_endpoint": true,
"endpoints": [
{
"endpoint": "/accounts/{id}/widgets",
"method": "GET",
"output_encoding": "no-op",
"backend": [{"url_pattern": "/__debug/gizmos"}]
},
{
"endpoint": "/accounts/{id}/gizmos",
"method": "GET",
"output_encoding": "no-op",
"backend": [{"url_pattern": "/__debug/gizmos"}]
}
]
}
Curls:
~ ❯ curl http://localhost:8080/accounts/12/gizmos
{"message":"pong"}
~ ❯ curl http://localhost:8080/accounts/12/giszmos
404 page not found
~ ❯ curl http://localhost:8080/accounts/12/widgets
{"message":"pong"}
~ ❯ curl http://localhost:8080/accounts/1dasdasd2/widgets
{"message":"pong"}
~ ❯ curl http://localhost:8080/accountsa/1dasdasd2/widgets
404 page not found
~ ❯ curl http://localhost:8080/accounts/1234/widgets
{"message":"pong"}
~ ❯ curl http://localhost:8080/accounts/1234/widgetsaaa
404 page not found
Same here, my friends. Here is the conf file. It's kind of large...
curl -i [your-host]/group/v2/units
Hey, you are facing a problem as described in the issues #779, #325, #386, #423 and #632 related to routing conflicts leading to errors when using automated processes to generate configuration files with multiple endpoints.
This is indeed a known issue with the router package used internally by KrakenD. We have communicated with the maintainers of the router package about this problem twice (https://github.com/gin-gonic/gin/issues/2959). Initially, there was an attempt to fix it, but unfortunately, that effort did not fully resolve the issue. We are waiting for the package maintainers' response to find a permanent solution.
In the meantime, the workaround you've discovered —disabling the automatic redirect— remains the only method to prevent these panics. This situation occurs when a 404 response is expected for a request to a path that overlaps with several patterns but matches none of them.
I've created a new issue in the gin project (https://github.com/gin-gonic/gin/issues/3972), hoping to get some attention because it looks like the old one is getting none since it's already closed and marked as fixed
Hi @alombarte I encountered the above and disable_redirect_fixed_path
: true
fixed the issue, however, What's the consequences of disabling the automatic redirect?
Environment info:
Describe the bug
My gateway has a number of routes that share a prefix -- eg.
/accounts/{id}/widgets
,/accounts/{id}/gizmos
, etc. These endpoints all route as expected. But if a request is received for a non-existent endpoint that uses the common prefix, this causes krakend to panic.The panic is handled and logged -- the service does not crash -- but no response is sent to the caller.
Your configuration file:
The backends really don't matter here, we never get there in this example.
Commands used
krakend run -c /etc/krakend/krakend.json
Test commands:
Expected behavior
I would expect a query against a undefined endpoint to resolve consistently (502, 404, not particularly choosy as long as it's consistent) and not panic.
In my current version of Krakend, the expected behavior is a 404:
instead of:
... which is what happens due to the panic.
Logs
Additional context I'm actually running a custom plugin so my stack trace might look weird (had to remove the bits specific to my company's application due to policy.) However since #779 looks suspiciously like the same thing I'm seeing, I'm quite certain this hasn't anything to do with any custom code.
Due to the nature of my application, I can't use
"disable_redirect_fixed_path": true
, which I understand from #779 may be a workaround.