caddyserver / caddyserver/cache-handler

Can not flush cache

Open
#140 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
393
Forks
28
Avg merge
32m
Merged PRs (30d)
1

Description

caddy version: 1.11.2

$ curl -v -X PURGE http://localhost:2019/souin-api/souin/flush
* Host localhost:2019 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:2019...
* Connected to localhost (::1) port 2019
* using HTTP/1.x
> PURGE /souin-api/souin/flush HTTP/1.1
> Host: localhost:2019
> User-Agent: curl/8.14.1
> Accept: */*
> 
* Request completely sent off
* Empty reply from server
* shutting down connection #0
curl: (52) Empty reply from server

log

{"level":"info","ts":1773995888.740839,"logger":"admin.api","msg":"received request","method":"PURGE","host":"localhost:2019","uri":"/souin-api/souin/flush","remote_ip":"10.88.0.112","remote_port":"54338","headers":{"Accept":["*/*"],"User-Agent":["curl/8.14.1"]}}
{"level":"info","ts":1773995888.7425144,"msg":"http: panic serving 10.88.0.112:54338: runtime error: invalid memory address or nil pointer dereference\ngoroutine 2663 [running]:\nnet/http.(*conn).serve.func1()\n\tnet/http/server.go:1907 +0xbd\npanic({0x1c7bd00?, 0x37542c0?})\n\truntime/panic.go:860 +0x13a\ngithub.com/darkweak/souin/pkg/api.(*SouinAPI).HandleRequest(0x2514e81b5020, {0x23581f0, 0x2514e9083110}, 0x2514e8130140)\n\tgithub.com/darkweak/souin@v1.7.7/pkg/api/souin.go:316 +0x931\ngithub.com/caddyserver/cache-handler.(*adminAPI).handleAPIEndpoints(0x2514e8643050?, {0x23581f0, 0x2514e9083110}, 0x2514e8130140)\n\tgithub.com/caddyserver/cache-handler@v0.16.0/admin.go:41 +0xf2\ngithub.com/caddyserver/caddy/v2.AdminHandlerFunc.ServeHTTP(0x425234?, {0x23581f0?, 0x2514e9083110?}, 0x2514e925aab0?)\n\tgithub.com/caddyserver/caddy/v2@v2.11.2/admin.go:1360 +0x29\ngithub.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.(*AdminConfig).newAdminHandler.func2.func6({0x23581f0, 0x2514e9083110}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/v2@v2.11.2/admin.go:248 +0x7b\nnet/http.HandlerFunc.ServeHTTP(0x2358580?, {0x23581f0?, 0x2514e9083110?}, 0x2514e860b750?)\n\tnet/http/server.go:2286 +0x29\ngithub.com/caddyserver/caddy/v2.(*AdminConfig).newAdminHandler.func1.instrumentHandlerCounter.1({0x2358580?, 0x2514e82fe5a0?}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/v2@v2.11.2/metrics.go:56 +0x6f\nnet/http.HandlerFunc.ServeHTTP(0x2514e927e3c0?, {0x2358580?, 0x2514e82fe5a0?}, 0x74c47f?)\n\tnet/http/server.go:2286 +0x29\nnet/http.(*ServeMux).ServeHTTP(0x2514e8640f90?, {0x2358580, 0x2514e82fe5a0}, 0x2514e8130140)\n\tnet/http/server.go:2828 +0x1c7\ngithub.com/caddyserver/caddy/v2.adminHandler.serveHTTP({0x2514e927e3c0, 0x0, 0x0, {0x2514e7e86528, 0x1, 0x1}, 0x0}, {0x2358580, 0x2514e82fe5a0}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/v2@v2.11.2/admin.go:891 +0x793\ngithub.com/caddyserver/caddy/v2.adminHandler.ServeHTTP({0x2514e927e3c0, 0x0, 0x0, {0x2514e7e86528, 0x1, 0x1}, 0x0}, {0x2358580, 0x2514e82fe5a0}, 0x2514e8130140)\n\tgithub.com/caddyserver/caddy/v2@v2.11.2/admin.go:816 +0x7a5\nnet/http.serverHandler.ServeHTTP({0x2514e829d180?}, {0x2358580?, 0x2514e82fe5a0?}, 0x1?)\n\tnet/http/server.go:3311 +0x8e\nnet/http.(*conn).serve(0x2514e925aa20, {0x235da70, 0x2514e85e1380})\n\tnet/http/server.go:2073 +0x650\ncreated by net/http.(*Server).Serve in goroutine 2372\n\tnet/http/server.go:3464 +0x485"}

Caddyfile

{
	debug
	order cache before rewrite

	cache {
		api {
			souin
		}
	}
}

example.com {
    @cacheable {
        not path /
    }
    handle @cacheable {
        cache {
            ttl 120s
        }
    }

    file_server
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at pkg/api/souin.go:316, where the PURGE request to /souin-api/souin/flush panics, and compare it with the Caddyfile cache API configuration. Reproduce the request with the provided curl command and inspect the related API handler path. Done means the endpoint returns a response without a nil-pointer panic and flushes the cache as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.