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

panic when upstreams returns some 50x codes #554

Closed
Tracked by #558
Galacs opened this issue Sep 22, 2024 · 2 comments · Fixed by #567
Closed
Tracked by #558

panic when upstreams returns some 50x codes #554

Galacs opened this issue Sep 22, 2024 · 2 comments · Fixed by #567

Comments

@Galacs
Copy link

Galacs commented Sep 22, 2024

Hi, using Souin 1.7.1 and Traefik 3.1.4 with the following config:

services:
  app:
    build: .
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.app.rule=Host(`example.com`)"
      - "traefik.http.routers.app.entrypoints=web"
      - "traefik.http.services.app.loadbalancer.server.port=8080"

      - traefik.http.routers.app.middlewares=souin
      - traefik.http.middlewares.souin.plugin.souin.api.souin
      - traefik.http.middlewares.souin.plugin.souin.default_cache.ttl=200s

  reverse-proxy:
    image: traefik:v3.1
    command:
      - --log.level=DEBUG
      - --api.insecure=true
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --entryPoints.web.address=:80
      - --experimental.plugins.souin.modulename=github.com/darkweak/souin
      - --experimental.plugins.souin.version=v1.7.1
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

When the upstream returns any of the following codes: 500, 502, 503, I get a panic without any http response. Here is it:

2024-09-22T10:38:34Z ERR fmt/print.go:305 > plugins-storage/sources/gop-4038460229/src/github.com/darkweak/souin/plugins/traefik/vendor/github.com/darkweak/souin/pkg/middleware/middleware.go:260:12: panic: github.com/darkweak/souin/pkg/middleware.Upstream(...) module=github.com/darkweak/souin plugin=plugin-souin runtime=
2024-09-22T10:38:34Z ERR fmt/print.go:305 > plugins-storage/sources/gop-4038460229/src/github.com/darkweak/souin/plugins/traefik/vendor/github.com/darkweak/souin/pkg/middleware/middleware.go:543:19: panic: github.com/darkweak/souin/pkg/middleware.ServeHTTP.func(...) module=github.com/darkweak/souin plugin=plugin-souin runtime=
panic: reflect.Set: value of type *struct {} is not assignable to type error [recovered]
	panic: reflect.Set: value of type *struct {} is not assignable to type error [recovered]
	panic: reflect.Set: value of type *struct {} is not assignable to type error

goroutine 159 [running]:
github.com/traefik/yaegi/interp.runCfg.func1()
	github.com/traefik/yaegi@v0.16.1/interp/run.go:226 +0x1ae
panic({0x49af8e0?, 0xc0037c14a0?})
	runtime/panic.go:785 +0x132
github.com/traefik/yaegi/interp.runCfg.func1()
	github.com/traefik/yaegi@v0.16.1/interp/run.go:226 +0x1ae
panic({0x49af8e0?, 0xc0037c14a0?})
	runtime/panic.go:785 +0x132
reflect.Value.assignTo({0x48e5580?, 0xa1587c0?, 0xa1587c0?}, {0x5abe71d, 0xb}, 0x4e009a0, 0xc003823c90)
	reflect/value.go:3358 +0x299
reflect.Value.Set({0x4e009a0?, 0xc003823c90?, 0x49afb20?}, {0x48e5580?, 0xa1587c0?, 0xc004a5c078?})
	reflect/value.go:2313 +0xe6
github.com/traefik/yaegi/interp._new.func1(0xc004a7aa50)
	github.com/traefik/yaegi@v0.16.1/interp/run.go:3418 +0xba
github.com/traefik/yaegi/interp.runCfg(0xc004e94780, 0xc004a7aa50, 0xc003823c80?, 0x49af8e0?)
	github.com/traefik/yaegi@v0.16.1/interp/run.go:234 +0x265
github.com/traefik/yaegi/interp.genFunctionWrapper.func1.1({0xc003415e00, 0x5, 0x8?})
	github.com/traefik/yaegi@v0.16.1/interp/run.go:1042 +0x7a5
reflect.Value.call({0xc002595880?, 0xc0023dc8d0?, 0x0?}, {0x5aa6ab6, 0x4}, {0xc003415d80, 0x5, 0xc0031154f0?})
	reflect/value.go:581 +0xca6
reflect.Value.Call({0xc002595880?, 0xc0023dc8d0?, 0x47b089?}, {0xc003415d80?, 0xc0031154f0?, 0x4bf2360?})
	reflect/value.go:365 +0xb9
github.com/traefik/yaegi/interp.call.func9.2({0xc003415d80?, 0xc0023dc8d0?, 0x0?})
	github.com/traefik/yaegi@v0.16.1/interp/run.go:1310 +0x36
github.com/traefik/yaegi/interp.call.func9(0xc004a7a9a0)
	github.com/traefik/yaegi@v0.16.1/interp/run.go:1330 +0xcc5
github.com/traefik/yaegi/interp.runCfg(0xc004f2ba40, 0xc004a7a9a0, 0xc0050bb260?, 0x0?)
	github.com/traefik/yaegi@v0.16.1/interp/run.go:234 +0x265
github.com/traefik/yaegi/interp.getFunc.func1.1({0xa1587c0, 0x0, 0x0?})
	github.com/traefik/yaegi@v0.16.1/interp/run.go:1919 +0x58d
reflect.Value.call({0x48e5c40?, 0xc0023dc7b0?, 0x13?}, {0x5aa6ab6, 0x4}, {0xa1587c0, 0x0, 0x0?})
	reflect/value.go:581 +0xca6
reflect.Value.Call({0x48e5c40?, 0xc0023dc7b0?, 0xa?}, {0xa1587c0?, 0x7?, 0x0?})
	reflect/value.go:365 +0xb9
github.com/traefik/yaegi/interp.call.func9.2({0xa1587c0?, 0x4598f61?, 0xe?})
	github.com/traefik/yaegi@v0.16.1/interp/run.go:1310 +0x36
created by github.com/traefik/yaegi/interp.call.func9 in goroutine 147
	github.com/traefik/yaegi@v0.16.1/interp/run.go:1322 +0xf4f

This configuration seems to work when the upstreams returns any other http status codes. And I also tried older versions of Souin and Traefik but that didn't change the issue.

@darkweak
Copy link
Owner

darkweak commented Oct 9, 2024

Hey, thank you @Galacs for your issue, I'll try to fix that asap.

@xudongcc
Copy link

@darkweak I tested it under treafik v3.1.4 and souin v1.7.5, it seems that the problem has not been solved.

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

Successfully merging a pull request may close this issue.

3 participants