repo
stringlengths
5
53
pr_number
int32
1
321k
task_type
stringclasses
2 values
issue_text
stringlengths
0
81.2k
pr_title
stringlengths
1
319
pr_body
stringlengths
0
105k
base_sha
stringlengths
40
40
head_sha
stringlengths
40
40
gold_diff
stringlengths
0
202M
changed_files
listlengths
0
100
review_threads
listlengths
0
100
test_patch
stringlengths
0
23.4M
merged
bool
1 class
valyala/fasthttp
2,264
issue_to_patch
bug: temporary file leak when file compression fails ## Description In `fs.go:1586-1629`, if `os.Create(tmpFilePath)` succeeds but the compression step fails, the temporary file is not cleaned up: ```go zf, err := os.Create(tmpFilePath) // ... compression fails ... // tmpFilePath remains on disk ``` ## Impact - St...
fix(fs): remove temporary file when compression fails
compressFileNolock created a ".tmp" file but left it on disk when the compression copy, os.Chtimes, or os.Rename step failed, leaking partial files that accumulate over time. Remove the temporary file in each error path. Fixes #2239
46bfd1b9d8cbf5df6d6e5c446224f276be638d5f
d00e59876c36a7b886fdd07c71eebaf6ea38107b
diff --git a/fs.go b/fs.go index ef38c1caeb..1e33682886 100644 --- a/fs.go +++ b/fs.go @@ -1617,13 +1617,16 @@ func (h *fsHandler) compressFileNolock( _ = zf.Close() _ = f.Close() if err != nil { + _ = os.Remove(tmpFilePath) return nil, fmt.Errorf("error when compressing file %q to %q: %w", filePath, tmpFileP...
[ "fs.go", "fs_test.go" ]
[]
diff --git a/fs_test.go b/fs_test.go index 1f85b8901a..313e0176b1 100644 --- a/fs_test.go +++ b/fs_test.go @@ -3,8 +3,10 @@ package fasthttp import ( "bufio" "bytes" + "errors" "fmt" "io" + iofs "io/fs" "math/rand" "os" "path/filepath" @@ -782,6 +784,42 @@ func runFSCompressSingleThread(t *testing.T, fs ...
true
valyala/fasthttp
2,205
issue_to_patch
Update to go1.25 as minimal version
e9208ecebf0c102176bb0635043c17333b10401d
65c0c0454cb55fa942032b0cf79bde3186f57152
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b38b7858bf..cc230c8c2d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,22 +2,22 @@ name: Test on: push: branches: - - master + - master pull_request: jobs: test: strategy: fail-f...
[ ".github/workflows/test.yml", "README.md", "client_test.go", "go.mod", "go.sum" ]
[]
diff --git a/client_test.go b/client_test.go index efd73f89d6..844c46c3e1 100644 --- a/client_test.go +++ b/client_test.go @@ -1493,9 +1493,7 @@ func TestHostClientMaxConnsWithDeadline(t *testing.T) { } for range 5 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { req := AcquireRequest() ...
true
valyala/fasthttp
2,274
issue_to_patch
security: TLS verification silently disabled for malformed addresses ## Description In `client.go:2048-2055`, when `tlsServerName(addr)` fails to parse the address (returns `"*"`), the code sets `InsecureSkipVerify = true`: ```go if c.ServerName == "" { serverName := tlsServerName(addr) if serverName == "*" ...
security: TLS verification silently disabled for malformed addresses (#2236)
Fixes #2236.
ab3bc8550d71df63674c953d17c1118019c984a1
0d9229e97c3e1f3f7d62d17c49d58a0b3a214e0d
diff --git a/client.go b/client.go index ca050c8126..ce6b5b12c6 100644 --- a/client.go +++ b/client.go @@ -2038,7 +2038,7 @@ func (c *HostClient) ReleaseReader(br *bufio.Reader) { } } -func newClientTLSConfig(c *tls.Config, addr string) *tls.Config { +func newClientTLSConfig(c *tls.Config, addr string) (*tls.Confi...
[ "client.go", "client_test.go" ]
[]
diff --git a/client_test.go b/client_test.go index 93de5acc0e..803c8ffd36 100644 --- a/client_test.go +++ b/client_test.go @@ -404,6 +404,41 @@ func testPipelineClientDoOnce(t *testing.T, c *PipelineClient) { } } +func TestPipelineClientTLSMalformedAddrFailsBeforeDial(t *testing.T) { + t.Parallel() + + c := &Pipel...
true
valyala/fasthttp
2,286
issue_to_patch
bug: filesLockMap grows unboundedly, leaking memory ## Description `filesLockMap` in `fs.go:1929-1934` uses a `sync.Map` that stores a mutex for every unique compressed file path ever encountered. Over a long-running server serving many unique files, this map grows without bound: ```go var filesLockMap sync.Map fun...
bug: filesLockMap grows unboundedly, leaking memory (#2256)
Fixes #2256.
6c530c5b81c580fb6b26732efa05652cf88a1aea
863d51c78a7782312e710ed692814a339e2f0835
diff --git a/fs.go b/fs.go index ef38c1caeb..256e5a2902 100644 --- a/fs.go +++ b/fs.go @@ -1560,12 +1560,13 @@ func (h *fsHandler) compressAndOpenFSFile(filePath, fileEncoding string) (*fsFil return nil, fmt.Errorf("cannot determine absolute path for %q: %v", compressedFilePath, err) } - flock := getFileLock(abs...
[ "fs.go", "fs_test.go" ]
[]
diff --git a/fs_test.go b/fs_test.go index 1f85b8901a..cc283adf74 100644 --- a/fs_test.go +++ b/fs_test.go @@ -772,6 +772,106 @@ func TestFSCompressSingleThreadSkipCache(t *testing.T) { }) } +func TestFileLockRefCountUsesPathLock(t *testing.T) { + path := "/tmp/" + t.Name() + otherPath := path + "-other" + t.Clean...
true
valyala/fasthttp
2,285
issue_to_patch
bug: file descriptor leak on z/OS s390x when FcntlInt fails ## Description `tcplisten/socket_zos_s390x.go:11-18` leaks the socket file descriptor when `FcntlInt` fails: ```go fd, err := unix.Socket(domain, typ, proto) // succeeds _, err = unix.FcntlInt(...) // overwrites err _, err = unix.FcntlInt(...
bug: file descriptor leak on z/OS s390x when FcntlInt fails (#2255)
Fixes #2255.
6c530c5b81c580fb6b26732efa05652cf88a1aea
f93ea072196afda229ed27c301f565bd60cd013e
diff --git a/tcplisten/socket_zos_s390x.go b/tcplisten/socket_zos_s390x.go index 998baa9ee9..8d13ae0591 100644 --- a/tcplisten/socket_zos_s390x.go +++ b/tcplisten/socket_zos_s390x.go @@ -10,10 +10,18 @@ import ( func newSocketCloexec(domain, typ, proto int) (int, error) { fd, err := unix.Socket(domain, typ, proto)...
[ "tcplisten/socket_zos_s390x.go" ]
[]
true
valyala/fasthttp
2,284
issue_to_patch
security: SO_REUSEADDR on Windows enables port hijacking ## Description `reuseport/reuseport_windows.go:14` uses `SO_REUSEADDR` as an alternative to `SO_REUSEPORT`. However, on Windows, `SO_REUSEADDR` allows **any** process to bind to the same address, unlike POSIX `SO_REUSEPORT` which requires the same user/group. T...
security: SO_REUSEADDR on Windows enables port hijacking (#2254)
Fixes #2254.
6c530c5b81c580fb6b26732efa05652cf88a1aea
e1f17cc2b09fba03c5fe21964da6faefda4d9a5b
diff --git a/reuseport/reuseport_windows.go b/reuseport/reuseport_windows.go index bf5c312cbe..981c3b27ed 100644 --- a/reuseport/reuseport_windows.go +++ b/reuseport/reuseport_windows.go @@ -16,8 +16,12 @@ var listenConfig = net.ListenConfig{ }, } -// Listen returns TCP listener with SO_REUSEADDR option set, SO_RE...
[ "reuseport/reuseport_windows.go" ]
[]
true
valyala/fasthttp
2,283
issue_to_patch
bug: file descriptor leak in prefork parent process ## Description In `prefork/prefork.go:226-233`, `tcplistener.File()` dups the listener fd. The dup'd `*os.File` is stored in `p.files` and passed to children via `ExtraFiles`, but it is **never closed in the parent process**. `p.ln.Close()` only closes the original ...
bug: file descriptor leak in prefork parent process (#2253)
Fixes #2253.
6c530c5b81c580fb6b26732efa05652cf88a1aea
3fa51dacaee5b82802a5c045d711c5efd50567e6
diff --git a/prefork/prefork.go b/prefork/prefork.go index 52a7a886cb..c4ee3e24ca 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -20,7 +20,8 @@ const ( ) var ( - defaultLogger = Logger(log.New(os.Stderr, "", log.LstdFlags)) + defaultLogger = Logger(log.New(os.Stderr, "", log.LstdFlags)) + tcpListener...
[ "prefork/prefork.go", "prefork/prefork_test.go" ]
[]
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index d358b5174e..37856e5e3e 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -11,6 +11,7 @@ import ( "runtime" "sync" "testing" + "time" "github.com/valyala/fasthttp" ) @@ -135,6 +136,89 @@ func Test_setTCPListenerFiles(t *t...
true
valyala/fasthttp
2,282
issue_to_patch
bug: SetBodySizePoolLimit data race — plain int written without synchronization ## Description `SetBodySizePoolLimit` in `http.go:27-30` writes to `requestBodyPoolSizeLimit` and `responseBodyPoolSizeLimit` (plain `int` variables) without synchronization: ```go func SetBodySizePoolLimit(reqBodyLimit, respBodyLimit in...
bug: SetBodySizePoolLimit data race — plain int written without synchronization (#2252)
Fixes #2252.
6c530c5b81c580fb6b26732efa05652cf88a1aea
b8a4764f3d2b41ac6920129bdc806a6e2ccdc0ad
diff --git a/http.go b/http.go index 27b77da508..5e4fdfbd00 100644 --- a/http.go +++ b/http.go @@ -12,21 +12,22 @@ import ( "net" "os" "sync" + "sync/atomic" "time" "github.com/valyala/bytebufferpool" ) var ( - requestBodyPoolSizeLimit = -1 - responseBodyPoolSizeLimit = -1 + requestBodyPoolSizeLimit i...
[ "http.go" ]
[]
true
valyala/fasthttp
2,281
issue_to_patch
bug: AppendCert/AppendCertEmbed not thread-safe ## Description `AppendCert` and `AppendCertEmbed` in `server.go:1879-1898` append to `s.TLSConfig.Certificates` without holding `s.mu`: ```go func (s *Server) AppendCert(certFile, keyFile string) error { // ... no s.mu.Lock() ... s.TLSConfig.Certificates = appe...
bug: AppendCert/AppendCertEmbed not thread-safe (#2251)
Fixes #2251.
6c530c5b81c580fb6b26732efa05652cf88a1aea
12447ada2e798acb78ed2451cf5df63fc4295f6b
diff --git a/server.go b/server.go index 5cfe880a8d..bba5b75369 100644 --- a/server.go +++ b/server.go @@ -1825,16 +1825,19 @@ func (s *Server) ServeTLS(ln net.Listener, certFile, keyFile string) error { s.configTLS() configHasCert := len(s.TLSConfig.Certificates) > 0 || s.TLSConfig.GetCertificate != nil if !conf...
[ "server.go", "server_test.go" ]
[]
diff --git a/server_test.go b/server_test.go index 9701de6f1e..e1760ca165 100644 --- a/server_test.go +++ b/server_test.go @@ -1171,6 +1171,33 @@ func TestServerTLS(t *testing.T) { } } +func TestServerAppendCertEmbedConcurrent(t *testing.T) { + t.Parallel() + + certData, keyData, err := GenerateTestCertificate("lo...
true
valyala/fasthttp
2,280
issue_to_patch
bug: closeIdleConns TOCTOU race with serveConn idle timestamp ## Description `closeIdleConns` in `server.go:3078-3089` reads `idleConnTime` under `idleConnsMu.Lock()`, but `serveConn` writes `idleConnTime` at `server.go:2671` outside the mutex: ```go // serveConn line 2670-2671 (no lock held) idleConnTime.Store(time...
bug: closeIdleConns TOCTOU race with serveConn idle timestamp (#2250)
Fixes #2250.
6c530c5b81c580fb6b26732efa05652cf88a1aea
57310a349f30719f15843159bca77e854e8e9500
diff --git a/server.go b/server.go index 5cfe880a8d..29fedef2fd 100644 --- a/server.go +++ b/server.go @@ -2365,9 +2365,8 @@ func (s *Server) serveConn(c net.Conn) error { ctx.Response.secureErrorLogMessage = s.SecureErrorLogMessage if err == nil { - s.setState(c, StateActive) - idleConnTime.Store(0) + ...
[ "server.go", "server_test.go" ]
[]
diff --git a/server_test.go b/server_test.go index 9701de6f1e..88f1271946 100644 --- a/server_test.go +++ b/server_test.go @@ -3473,6 +3473,59 @@ func TestTimeoutHandlerTimeoutReuse(t *testing.T) { } } +func TestServerConnStateSeesIdleMarkers(t *testing.T) { + t.Parallel() + + activeCh := make(chan int64, 1) + idl...
true
valyala/fasthttp
2,279
issue_to_patch
bug: fasthttpproxy dialers return nil DialFunc on error, causing panic ## Description In `fasthttpproxy`, all four public dialer constructors discard the error from `GetDialFunc`: ```go // http.go:33, proxy_env.go:37, socks5.go:18, socks5.go:32 dialFunc, _ := d.GetDialFunc(false) // error ignored return dialFunc ...
bug: fasthttpproxy dialers return nil DialFunc on error, causing panic (#2248)
Fixes #2248.
6c530c5b81c580fb6b26732efa05652cf88a1aea
62d121aa7719df75e9265023efbee1b399ea517f
diff --git a/fasthttpproxy/dialer.go b/fasthttpproxy/dialer.go index 49753ec0c1..6176cc2956 100644 --- a/fasthttpproxy/dialer.go +++ b/fasthttpproxy/dialer.go @@ -21,6 +21,15 @@ var ( tmpURL = &url.URL{Scheme: httpsScheme, Host: "example.com"} ) +func dialFuncOrError(dialFunc fasthttp.DialFunc, err error) fa...
[ "fasthttpproxy/dialer.go", "fasthttpproxy/dialer_test.go", "fasthttpproxy/http.go", "fasthttpproxy/proxy_env.go", "fasthttpproxy/socks5.go" ]
[]
diff --git a/fasthttpproxy/dialer_test.go b/fasthttpproxy/dialer_test.go index 9b4fea5978..3bbd2d1e6b 100644 --- a/fasthttpproxy/dialer_test.go +++ b/fasthttpproxy/dialer_test.go @@ -261,6 +261,65 @@ func TestHTTPProxyDialRejectsTargetAddrContainingNewlines(t *testing.T) { } } +func TestProxyDialerConstructorsRetu...
true
valyala/fasthttp
2,278
issue_to_patch
bug: fasthttpadaptor writer leak, data race, and crash on handler panic ## Description In `fasthttpadaptor/adaptor.go`, there are three issues: ### 1. Writer pool leak in modeHijacked (line 176-178) When the handler calls `Hijack()`, the main goroutine returns without calling `releaseWriter(w)`. The buffered writer'...
bug: fasthttpadaptor writer leak, data race, and crash on handler panic (#2246)
Fixes #2246.
6c530c5b81c580fb6b26732efa05652cf88a1aea
35121dc850a0d753ae91167b9eedbe1c1f28ea71
diff --git a/fasthttpadaptor/adaptor.go b/fasthttpadaptor/adaptor.go index 60ea5dc1d6..7fbf3deb81 100644 --- a/fasthttpadaptor/adaptor.go +++ b/fasthttpadaptor/adaptor.go @@ -174,6 +174,7 @@ func NewFastHTTPHandler(h http.Handler) fasthttp.RequestHandler { close(w.streamReady) case modeHijacked: + releaseWri...
[ "fasthttpadaptor/adaptor.go", "fasthttpadaptor/adaptor_test.go" ]
[]
diff --git a/fasthttpadaptor/adaptor_test.go b/fasthttpadaptor/adaptor_test.go index fbc63b517d..4883f53e0e 100644 --- a/fasthttpadaptor/adaptor_test.go +++ b/fasthttpadaptor/adaptor_test.go @@ -703,3 +703,49 @@ func TestNewFastHTTPHandlerPanic(t *testing.T) { t.Error("expected panic, but it didn't happen") } + +f...
true
valyala/fasthttp
2,277
issue_to_patch
bug: InMemoryListener deadlock under high concurrency ## Description In `fasthttputil/inmemory_listener.go:117-128`, `DialWithLocalAddr` holds `ln.lock` while sending to `ln.conns` (line 120) AND waiting for `<-accepted` (line 122): ```go func (ln *inMemoryListener) DialWithLocalAddr(...) (net.Conn, error) { ln....
bug: InMemoryListener deadlock under high concurrency (#2245)
Fixes #2245.
6c530c5b81c580fb6b26732efa05652cf88a1aea
e56e257e807797b12defeb08e1705672c7a94918
diff --git a/fasthttputil/inmemory_listener.go b/fasthttputil/inmemory_listener.go index 2df46640b5..3d345bd7ae 100644 --- a/fasthttputil/inmemory_listener.go +++ b/fasthttputil/inmemory_listener.go @@ -16,6 +16,7 @@ var ErrInmemoryListenerClosed = errors.New("InmemoryListener is already closed: type InmemoryListener ...
[ "fasthttputil/inmemory_listener.go", "fasthttputil/inmemory_listener_test.go" ]
[]
diff --git a/fasthttputil/inmemory_listener_test.go b/fasthttputil/inmemory_listener_test.go index 6e4b1f1c37..943b3296ab 100644 --- a/fasthttputil/inmemory_listener_test.go +++ b/fasthttputil/inmemory_listener_test.go @@ -3,6 +3,7 @@ package fasthttputil import ( "bytes" "context" + "errors" "fmt" "io" "net...
true
valyala/fasthttp
2,276
issue_to_patch
bug: body stream leak in compression methods when response is discarded ## Description In `compress.go`, `brotli.go`, and `zstd.go`, when a response has a body stream and the caller requests compression, the original body stream is wrapped in a `NewStreamReader`. The compression methods (`brotliBody`, `gzipBody`, `de...
bug: body stream leak in compression methods when response is discarded (#2244)
Fixes #2244.
6c530c5b81c580fb6b26732efa05652cf88a1aea
b9f0a29167ea9119a4473534d674375ecb04d0e0
diff --git a/http.go b/http.go index 27b77da508..4682235bde 100644 --- a/http.go +++ b/http.go @@ -1883,22 +1883,7 @@ func (resp *Response) brotliBody(level int) { // Do not care about memory allocations here, since brotli is slow // and allocates a lot of memory by itself. - bs := resp.bodyStream - resp.body...
[ "http.go", "http_test.go" ]
[]
diff --git a/http_test.go b/http_test.go index 17c4fc9eba..c2d7cf6846 100644 --- a/http_test.go +++ b/http_test.go @@ -12,6 +12,7 @@ import ( "reflect" "strconv" "strings" + "sync" "testing" "time" @@ -3376,6 +3377,171 @@ func TestResponseBodyStream(t *testing.T) { }) } +func TestResponseCompressedBody...
true
valyala/fasthttp
2,275
issue_to_patch
bug: double concurrency counter increment in ServeConn causes counter leak ## Description `Server.ServeConn` increments `s.concurrency` at `server.go:2157`, then calls `s.serveConn` which increments it **again** at `server.go:2250`. The cleanup in `serveConnCleanup` at `server.go:2245` only decrements by 1. The outer...
bug: double concurrency counter increment in ServeConn causes counter leak (#2238)
Fixes #2238.
6c530c5b81c580fb6b26732efa05652cf88a1aea
73b7a6c4c78b32a87fe0ce16e4276bed7293722f
diff --git a/server.go b/server.go index 5cfe880a8d..5af0b5bd31 100644 --- a/server.go +++ b/server.go @@ -2154,19 +2154,16 @@ func (s *Server) ServeConn(c net.Conn) error { c = pic } - n := int(s.concurrency.Add(1)) // #nosec G115 - if n > s.getConcurrency() { - s.concurrency.Add(^uint32(0)) + if !s.tryAcquire...
[ "server.go", "server_test.go" ]
[]
diff --git a/server_test.go b/server_test.go index 9701de6f1e..8fd076fba7 100644 --- a/server_test.go +++ b/server_test.go @@ -3962,6 +3962,34 @@ func TestServeConnSingleRequest(t *testing.T) { verifyResponse(t, br, 200, "aaa", "requestURI=/foo/bar?baz, host=google.com") } +func TestServeConnCountsConcurrencyOnce(...
true
valyala/fasthttp
2,273
issue_to_patch
bug: TCPDialer.tcpAddrsClean() goroutine leaks — no shutdown mechanism ## Description `TCPDialer.tcpAddrsClean()` (tcpdialer.go:301) is launched via `go d.tcpAddrsClean()` inside a `sync.Once`. Once started, this goroutine **never exits** — it runs an infinite `for { time.Sleep(time.Second); ... }` loop with no done ...
bug: TCPDialer.tcpAddrsClean() goroutine leaks — no shutdown mechanism (#2222)
Fixes #2222.
6c530c5b81c580fb6b26732efa05652cf88a1aea
1f2e008757c1c9065562abaed621eed43e74701e
diff --git a/tcpdialer.go b/tcpdialer.go index fa9e5d6035..be6abafc03 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -146,7 +146,8 @@ type TCPDialer struct { concurrencyCh chan struct{} - tcpAddrsMap sync.Map + tcpAddrsMap sync.Map + cleanerRunning atomic.Bool // Concurrency controls the maximum number of...
[ "client_test.go", "tcpdialer.go" ]
[]
diff --git a/client_test.go b/client_test.go index 1350ebafd1..dcabc0fe8f 100644 --- a/client_test.go +++ b/client_test.go @@ -3776,6 +3776,72 @@ func TestTCPDialerFlushDNSCache(t *testing.T) { } } +func TestTCPDialerDNSCleanerStopsAndRestarts(t *testing.T) { + interval := atomic.LoadInt64(&tcpAddrsCleanInterval) ...
true
valyala/fasthttp
2,272
issue_to_patch
bug: data race on pipeline client c.chR during worker drain ## Description In `pipelineConnClient.worker()` (client.go:2898), after `worker()` returns, it drains remaining items from `c.chR`: ```go // client.go:2898-2902 for len(c.chR) > 0 { w := <-c.chR w.tryDeliver(errConnectionReset, nil) } ``` However, ...
bug: data race on pipeline client c.chR during worker drain (#2220)
Fixes #2220.
289229aad3bd8a37ce3574ae8e07e8179047ca6f
2def92c418b93319caf10cea5265e5efbeac9757
diff --git a/client.go b/client.go index 9269f51fe6..ca050c8126 100644 --- a/client.go +++ b/client.go @@ -2511,10 +2511,9 @@ type pipelineConnClient struct { Dial DialFunc TLSConfig *tls.Config - chW chan *pipelineWork - chR chan *pipelineWork tlsConfig *tls.Config + chs *pipelineConnC...
[ "client.go", "client_test.go" ]
[]
diff --git a/client_test.go b/client_test.go index 1350ebafd1..45d2f3adc6 100644 --- a/client_test.go +++ b/client_test.go @@ -295,6 +295,115 @@ func TestPipelineClientIssue832(t *testing.T) { } } +func TestPipelineClientRestartsAfterIdle(t *testing.T) { + t.Parallel() + + ln := fasthttputil.NewInmemoryListener() ...
true
valyala/fasthttp
2,271
issue_to_patch
bug: FS cache cleaner goroutine leaks when CleanStop is nil (default) ## Description `inMemoryCacheManager.handleCleanCache()` (fs.go:922) spawns a background goroutine for cache cleanup. When `FS.CleanStop` is `nil` (the zero-value default), the goroutine enters an infinite loop with no exit path: ```go // fs.go:10...
bug: FS cache cleaner goroutine leaks when CleanStop is nil (default) (#2218), #2247
Fixes #2218. Fixes #2247.
6c530c5b81c580fb6b26732efa05652cf88a1aea
1b5344eeef59cf0f7974c6a6faaa4902e4be1211
diff --git a/fs.go b/fs.go index ef38c1caeb..03904d94b6 100644 --- a/fs.go +++ b/fs.go @@ -13,6 +13,7 @@ import ( "os" "path" "path/filepath" + "runtime" "sort" "strings" "sync" @@ -598,7 +599,16 @@ func (fs *FS) initRequestHandler() { h.filesystem = &osFS{} // It provides os.Open and os.Stat } - fs....
[ "fs.go", "fs_fs_test.go" ]
[]
diff --git a/fs_fs_test.go b/fs_fs_test.go index 9101f4bc33..e17767c332 100644 --- a/fs_fs_test.go +++ b/fs_fs_test.go @@ -56,6 +56,46 @@ func TestFSServeFileHead(t *testing.T) { } } +func TestServeFSDoesNotLeakCacheCleaner(t *testing.T) { + testFS := fstest.MapFS{ + "index.txt": {Data: []byte("body")}, + } + + r...
true
valyala/fasthttp
2,267
issue_to_patch
chore(deps): bump securego/gosec from 2.27.0 to 2.27.1
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.27.0 to 2.27.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/securego/gosec/releases">securego/gosec's releases</a>.</em></p> <blockquote> <h2>v2.27.1</h2> <h2>Changelog</h2> <ul> <li>9e6a9843d7a4a6e3e9a8539b0...
46bfd1b9d8cbf5df6d6e5c446224f276be638d5f
bd9d04f2a3f0f4cb0ecd909620d55d01a3662680
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 7613ff89ce..746b6fdd7d 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -16,6 +16,6 @@ jobs: steps: - uses: actions/checkout@v6 - name: Run Gosec Security Scanner - uses: secur...
[ ".github/workflows/security.yml" ]
[]
true
valyala/fasthttp
2,260
issue_to_patch
bug: FormFile returns (nil, nil) when MultipartForm.File is nil ## Description In `server.go:1147-1148`, `FormFile` returns `(nil, err)` when `mf.File == nil`. But at this point `err` is `nil` (from the successful `MultipartForm()` call), so the function returns `(nil, nil)` — no file header and no error. ```go mf, ...
fix(server): return ErrMissingFile when MultipartForm.File is nil
RequestCtx.FormFile previously returned (nil, nil) when the parsed multipart form had a nil File map: the code returned the err variable from the preceding successful MultipartForm() call, which is always nil at that point. Callers checking `if err != nil` proceeded with a nil *multipart.FileHeader, causing nil pointer...
bf00c3e2dfbe9b8e674968f54492a5ab996d35e3
438e4e4d09baa79b311606a975efd19d353ed13b
diff --git a/server.go b/server.go index d7439b566b..5cfe880a8d 100644 --- a/server.go +++ b/server.go @@ -1145,7 +1145,7 @@ func (ctx *RequestCtx) FormFile(key string) (*multipart.FileHeader, error) { return nil, err } if mf.File == nil { - return nil, err + return nil, ErrMissingFile } fhh := mf.File[key...
[ "server.go" ]
[ { "comment": "There's no need to add a test for such a simple change.", "path": "server_test.go", "hunk": "@@ -4890,3 +4890,29 @@ func TestRequestCtxInitShouldNotBeCanceledIssue1879(t *testing.T) {\n \t\tt.Fatal(err)\n \t}\n }\n+\n+// Regression test for #2235: FormFile must not return (nil, nil) when t...
true
valyala/fasthttp
2,261
issue_to_patch
chore(deps): bump securego/gosec from 2.26.1 to 2.27.0
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.26.1 to 2.27.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/securego/gosec/releases">securego/gosec's releases</a>.</em></p> <blockquote> <h2>v2.27.0</h2> <h2>Changelog</h2> <ul> <li>0a5c6504c46569257663726ac...
bf00c3e2dfbe9b8e674968f54492a5ab996d35e3
0a398a95a888666579706bc7835172e9ad6abe7c
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index ae031a98ea..7613ff89ce 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -16,6 +16,6 @@ jobs: steps: - uses: actions/checkout@v6 - name: Run Gosec Security Scanner - uses: secur...
[ ".github/workflows/security.yml" ]
[]
true
valyala/fasthttp
2,207
issue_to_patch
chore(deps): bump golang.org/x/net from 0.54.0 to 0.55.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.54.0 to 0.55.0. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/golang/net/commit/7770ec48d03fec35e378665337b4faca93c38423"><code>7770ec4</code></a> go.mod: update golang.org/x dependencies</li> <li><a href="https://github.com/gola...
e4e2651d9faad935afef5a700983a29d8d838c88
562e16fb958ac4de0c0629e5922fc79a948a3edf
diff --git a/go.mod b/go.mod index 5cece3b9f5..3a39bd0911 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/klauspost/compress v1.18.6 github.com/valyala/bytebufferpool v1.0.0 golang.org/x/crypto v0.52.0 - golang.org/x/net v0.54.0 + golang.org/x/net v0.55.0 golang.org/x/sys v0.45.0 ) diff...
[ "go.mod", "go.sum" ]
[]
true
valyala/fasthttp
2,208
issue_to_patch
chore(deps): bump golang.org/x/sys from 0.44.0 to 0.45.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.44.0 to 0.45.0. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/golang/sys/commit/397d5f80920585bc27433d878aba498d062f81e1"><code>397d5f8</code></a> unix: update to Linux kernel 7.0</li> <li><a href="https://github.com/golang/sys/c...
6d7682aa72d1f42e548d357138249c66862e8611
492f3bb03e64ad6dd4744509f2ce572eba2cf730
diff --git a/go.mod b/go.mod index 6d902e56b3..b35869ad66 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/valyala/bytebufferpool v1.0.0 golang.org/x/crypto v0.51.0 golang.org/x/net v0.54.0 - golang.org/x/sys v0.44.0 + golang.org/x/sys v0.45.0 ) require golang.org/x/text v0.37.0 // indire...
[ "go.mod", "go.sum" ]
[]
true
valyala/fasthttp
2,209
issue_to_patch
chore(deps): bump golang.org/x/crypto from 0.51.0 to 0.52.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.51.0 to 0.52.0. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/golang/crypto/commit/a1c0d9929856c8aba2b31f079340f00578eda803"><code>a1c0d99</code></a> go.mod: update golang.org/x dependencies</li> <li><a href="https://github...
6d7682aa72d1f42e548d357138249c66862e8611
041d201598c2c718b2d994e3cb045bec785a9a31
diff --git a/go.mod b/go.mod index 6d902e56b3..5cece3b9f5 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ require ( github.com/andybalholm/brotli v1.2.1 github.com/klauspost/compress v1.18.6 github.com/valyala/bytebufferpool v1.0.0 - golang.org/x/crypto v0.51.0 + golang.org/x/crypto v0.52.0 golang.org/x/net v0...
[ "go.mod", "go.sum" ]
[]
true
valyala/fasthttp
2,210
issue_to_patch
chore(deps): bump golangci/golangci-lint-action from 9.2.0 to 9.2.1
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 9.2.0 to 9.2.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/golangci/golangci-lint-action/releases">golangci/golangci-lint-action's releases</a>.</em></p> <blockquote> <h2>v9.2.1</...
6d7682aa72d1f42e548d357138249c66862e8611
4229d0668b738aaaa86005cf00cda043dc440a27
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 110bd69092..068e0dd3f5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,7 +23,7 @@ jobs: go-version: 1.26.x - run: go version - name: Run golangci-lint - uses: golangci/golangci-lint-action@...
[ ".github/workflows/lint.yml" ]
[]
true
valyala/fasthttp
2,201
issue_to_patch
Client: add aggregate connection pool metrics for observability ## Feature Request **Is your feature request related to a problem? Please describe.** The `fasthttp.Client` type is a multi-host wrapper that dynamically creates `HostClient` instances per hostname. While `HostClient` exposes `ConnsCount()` for per-host...
client: add aggregate connection count metrics
Adds Client.ConnsCount() and Client.IdleConnsCount(), aggregating across all managed HostClients (both http and https maps). Also adds HostClient.IdleConnsCount() since there was no public accessor for per-host idle count. Closes #2200
e9208ecebf0c102176bb0635043c17333b10401d
a6b1d0e0edb2c4c6dd1d3ad0daf45f44ceb96c00
diff --git a/client.go b/client.go index 6482ab2112..9269f51fe6 100644 --- a/client.go +++ b/client.go @@ -606,6 +606,36 @@ func (c *Client) CloseIdleConnections() { c.mLock.RUnlock() } +// ConnsCount returns total connection count across all HostClients managed by Client. +func (c *Client) ConnsCount() int { + c....
[ "client.go", "client_test.go" ]
[ { "comment": "This is already tested in the above test as well, please remove this test.", "path": "client_test.go", "hunk": "@@ -74,6 +74,64 @@ func TestCloseIdleConnections(t *testing.T) {\n \t}\n }\n \n+func TestClientConnectionCounts(t *testing.T) {\n+\tt.Parallel()\n+\n+\tln := fasthttputil.NewInme...
diff --git a/client_test.go b/client_test.go index efd73f89d6..a07e648137 100644 --- a/client_test.go +++ b/client_test.go @@ -74,6 +74,52 @@ func TestCloseIdleConnections(t *testing.T) { } } +func TestClientConnectionCounts(t *testing.T) { + t.Parallel() + + ln := fasthttputil.NewInmemoryListener() + + s := &Serv...
true
valyala/fasthttp
2,180
issue_to_patch
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
We've been working on reducing code duplication between Fiber and fasthttp's prefork package. Right now Fiber maintains its own prefork implementation (~200 lines) that reimplements most of what `fasthttp/prefork` already does - process spawning, child management, the recovery loop - just to hook into a few lifecycle e...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go", "prefork/prefork_test.go" ]
[ { "comment": "`doCommand` assumes a non-nil, already-started `*exec.Cmd` when `CommandProducer` is provided. If a producer returns `cmd` with `err == nil` but without calling `Start()`, `cmd.Process` will be nil and later access to `cmd.Process.Pid` will panic. Consider validating `cmd != nil && cmd.Process != ...
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
`doCommand` assumes a non-nil, already-started `*exec.Cmd` when `CommandProducer` is provided. If a producer returns `cmd` with `err == nil` but without calling `Start()`, `cmd.Process` will be nil and later access to `cmd.Process.Pid` will panic. Consider validating `cmd != nil && cmd.Process != nil` (and returning a ...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "`doCommand` assumes a non-nil, already-started `*exec.Cmd` when `CommandProducer` is provided. If a producer returns `cmd` with `err == nil` but without calling `Start()`, `cmd.Process` will be nil and later access to `cmd.Process.Pid` will panic. Consider validating `cmd != nil && cmd.Process != ...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
The `ListenAndServeTLS` doc comment is ambiguous/misleading about parameter meaning/order. This method takes `(addr, certKey, certFile)` but then passes `(certFile, certKey)` to `ServeTLSFunc`; please document explicitly that `certKey` is the key path and `certFile` is the certificate path (or rename parameters to matc...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "The `ListenAndServeTLS` doc comment is ambiguous/misleading about parameter meaning/order. This method takes `(addr, certKey, certFile)` but then passes `(certFile, certKey)` to `ServeTLSFunc`; please document explicitly that `certKey` is the key path and `certFile` is the certificate path (or ren...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
`Test_CommandProducer` shells out to `go version`, which makes the test depend on an external `go` binary being discoverable in PATH and can be flaky in minimal/embedded CI environments. Prefer a hermetic helper process approach (e.g., re-exec the test binary) or a platform-safe no-op command so the test only validates...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "`Test_CommandProducer` shells out to `go version`, which makes the test depend on an external `go` binary being discoverable in PATH and can be flaky in minimal/embedded CI environments. Prefer a hermetic helper process approach (e.g., re-exec the test binary) or a platform-safe no-op command so t...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
`Test_Listen_WithOnMasterDeath` doesn't exercise `OnMasterDeath` at all (it only calls `p.listen`, which ignores that callback), so the test name/purpose is misleading. Either rename it to reflect what it asserts (listener creation) or update it to actually cover the intended behavior without risking `os.Exit` during t...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "`Test_Listen_WithOnMasterDeath` doesn't exercise `OnMasterDeath` at all (it only calls `p.listen`, which ignores that callback), so the test name/purpose is misleading. Either rename it to reflect what it asserts (listener creation) or update it to actually cover the intended behavior without risk...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
New lifecycle callbacks (`OnChildSpawn`/`OnMasterReady`/`OnChildRecover`) are invoked inside `prefork`, but current tests only call these function fields directly and don't verify the prefork lifecycle wiring (order, arguments, and abort behavior on errors). Add an integration-style test that runs `prefork()` with a co...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "New lifecycle callbacks (`OnChildSpawn`/`OnMasterReady`/`OnChildRecover`) are invoked inside `prefork`, but current tests only call these function fields directly and don't verify the prefork lifecycle wiring (order, arguments, and abort behavior on errors). Add an integration-style test that runs...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Can't something be done with these errors? At least `p.logger().Print` them.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Can't something be done with these errors?\n\nAt least `p.logger().Print` them.", "path": "prefork/prefork.go", "hunk": "@@ -104,6 +130,22 @@ func (p *Prefork) logger() Logger {\n }\n \n func (p *Prefork) watchMaster(masterPID int) {\n+\tif runtime.GOOS == \"windows\" {\n+\t\t// On Windows...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Shouldn't we kill the child here?
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Shouldn't we kill the child here?", "path": "prefork/prefork.go", "hunk": "@@ -205,25 +278,47 @@ func (p *Prefork) prefork(addr string) (err error) {\n \n \tgoMaxProcs := runtime.GOMAXPROCS(0)\n \tsigCh := make(chan procSig, goMaxProcs)\n-\tchildProcs := make(map[int]*exec.Cmd)\n+\tchildPr...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
What exactly is the use case of `CommandProducer`? Right now it doesn't document how to handle the args or the `FASTHTTP_PREFORK_CHILD=1` env variable, or what to do with stdout and stderr. If it's only used for the executable maybe it's better to have it just return a string?
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "What exactly is the use case of `CommandProducer`? Right now it doesn't document how to handle the args or the `FASTHTTP_PREFORK_CHILD=1` env variable, or what to do with stdout and stderr.\n\nIf it's only used for the executable maybe it's better to have it just return a string?", "path": "pr...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Why add the error return value when it's just ignored?
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Why add the error return value when it's just ignored?", "path": "prefork/prefork.go", "hunk": "@@ -237,19 +332,27 @@ func (p *Prefork) prefork(addr string) (err error) {\n \t\tif exitedProcs > p.RecoverThreshold {\n \t\t\tp.logger().Printf(\"child prefork processes exit too many times, \"...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Shouldn't `OnChildSpawn` be called here as well? Or the documentation of `OnChildSpawn` should change.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Shouldn't `OnChildSpawn` be called here as well? Or the documentation of `OnChildSpawn` should change.", "path": "prefork/prefork.go", "hunk": "@@ -237,19 +341,26 @@ func (p *Prefork) prefork(addr string) (err error) {\n \t\tif exitedProcs > p.RecoverThreshold {\n \t\t\tp.logger().Printf(\...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Shouldn't this trigger `p.OnMasterDeath()`? Not being able to find the master process probably means it died right?
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Shouldn't this trigger `p.OnMasterDeath()`? Not being able to find the master process probably means it died right?", "path": "prefork/prefork.go", "hunk": "@@ -104,6 +133,26 @@ func (p *Prefork) logger() Logger {\n }\n \n func (p *Prefork) watchMaster(masterPID int) {\n+\tif runtime.GOOS ...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Doesn't the producer have to set `FASTHTTP_PREFORK_CHILD=1`? Otherwise `IsChild()` returns false and the listener won't be setup correctly. Please also add a comment that this is isn't required and what the default does.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Doesn't the producer have to set `FASTHTTP_PREFORK_CHILD=1`? Otherwise `IsChild()` returns false and the listener won't be setup correctly.\n\nPlease also add a comment that this is isn't required and what the default does.", "path": "prefork/prefork.go", "hunk": "@@ -77,6 +77,35 @@ type P...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Does it make sense to also provide the old pid as argument? That way any process management can know which pid was replaced?
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Does it make sense to also provide the old pid as argument? That way any process management can know which pid was replaced?", "path": "prefork/prefork.go", "hunk": "@@ -77,6 +77,35 @@ type Prefork struct {\n \t// It is recommended to set this to func() { os.Exit(1) } if no custom\n \t// c...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
The `go func(c *exec.Cmd, pid int) {` below actually needs to be above this line. If `OnChildSpawn` returns an error and the deferred cleanup happens it will call `Kill()` on each child. But after `Kill()` you always need to `Wait()` on the child to make sure it's cleaned up. If you don't `Wait()` it will hang as a zo...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "The `go func(c *exec.Cmd, pid int) {` below actually needs to be above this line.\n\nIf `OnChildSpawn` returns an error and the deferred cleanup happens it will call `Kill()` on each child.\nBut after `Kill()` you always need to `Wait()` on the child to make sure it's cleaned up. If you don't `Wai...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Same here, if the `Wait()` isn't before this `break` it will create a zombie process.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Same here, if the `Wait()` isn't before this `break` it will create a zombie process.", "path": "prefork/prefork.go", "hunk": "@@ -237,19 +345,34 @@ func (p *Prefork) prefork(addr string) (err error) {\n \t\tif exitedProcs > p.RecoverThreshold {\n \t\t\tp.logger().Printf(\"child prefork pr...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
This whole test only tests if the Go compiler works 🤷‍♂️ it doesn't test any functionality at all.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "This whole test only tests if the Go compiler works 🤷‍♂️ it doesn't test any functionality at all.", "path": "prefork/prefork_test.go", "hunk": "@@ -224,3 +226,281 @@ func Test_ListenAndServeTLSEmbed(t *testing.T) {\n \t\tt.Error(\"Prefork.ln is nil\")\n \t}\n }\n+\n+func Test_Prefork_Log...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Same here, what is this actually testing? These tests were obviously AI written, I'm not going to review tests you couldn't even bother to take the time to review yourself.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "Same here, what is this actually testing? These tests were obviously AI written, I'm not going to review tests you couldn't even bother to take the time to review yourself.", "path": "prefork/prefork_test.go", "hunk": "@@ -224,3 +226,281 @@ func Test_ListenAndServeTLSEmbed(t *testing.T) {\...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
No need to test this, `defaultRecoverThreshold` is so simple it really doesn't need a test.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "No need to test this, `defaultRecoverThreshold` is so simple it really doesn't need a test.", "path": "prefork/prefork_test.go", "hunk": "@@ -64,8 +71,22 @@ func Test_New(t *testing.T) {\n \t}\n }\n \n+func Test_defaultRecoverThreshold_SingleCore(t *testing.T) {\n+\tprev := runtime.GOMAXPR...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
No need to test this, this is just testing this statement only: ``` if p.Logger != nil { return p.Logger } ``` I trust that this if statement works and that nobody will break this in the future.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "No need to test this, this is just testing this statement only:\n```\n\tif p.Logger != nil {\n\t\treturn p.Logger\n\t}\n```\nI trust that this if statement works and that nobody will break this in the future.", "path": "prefork/prefork_test.go", "hunk": "@@ -224,3 +245,161 @@ func Test_Lis...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
This is a great catch! All tests running together and after this test would run on a single core. Never noticed!
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork_test.go b/prefork/prefork_test.go index 8236e124e4..004450b9e8 100644 --- a/prefork/prefork_test.go +++ b/prefork/prefork_test.go @@ -1,43 +1,80 @@ package prefork import ( + "errors" "fmt" - "math/rand" "net" "os" - "reflect" + "os/exec" "runtime" + "sync" + "sync/atomic" "te...
[ "prefork/prefork_test.go" ]
[ { "comment": "This is a great catch! All tests running together and after this test would run on a single core. Never noticed!", "path": "prefork/prefork_test.go", "hunk": "@@ -64,8 +71,22 @@ func Test_New(t *testing.T) {\n \t}\n }\n \n+func Test_defaultRecoverThreshold_SingleCore(t *testing.T) {\n+\tpr...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Doesn't it make more sense to do `return err` here? That way `ListenAndServe` returns with this error and it can properly be handled? Then you can also document in `OnChildSpawn` that returning an error will kill all childs and make `ListenAndServe` return that error.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Doesn't it make more sense to do `return err` here? That way `ListenAndServe` returns with this error and it can properly be handled?\n\nThen you can also document in `OnChildSpawn` that returning an error will kill all childs and make `ListenAndServe` return that error.", "path": "prefork/pre...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
You're calling `OnChildRecover` before `OnChildSpawn`. If `OnChildSpawn` returns an error than the child wasn't really recovered as everything will be shut down?
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "You're calling `OnChildRecover` before `OnChildSpawn`. If `OnChildSpawn` returns an error than the child wasn't really recovered as everything will be shut down?", "path": "prefork/prefork.go", "hunk": "@@ -237,19 +349,35 @@ func (p *Prefork) prefork(addr string) (err error) {\n \t\tif exi...
true
valyala/fasthttp
2,180
comment_to_fix
feat(prefork): Enhance prefork management with WatchMaster, CommandProducer, and Windows support
Moving `sigCh <- procSig...` to before `OnChildSpawn` was already enough to make sure we don't leave any zombies. Adding this additional `Wait()` now makes each child Waited on twice, which is usually not advised to do. See also: https://github.com/golang/go/blob/8594bf46218254ce5508e1500b92d4329f0a627c/src/os/exec_un...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
262ea09c9edbee3fcbedeccfa1441074e06cb2ba
diff --git a/prefork/prefork.go b/prefork/prefork.go index d883640147..1964ddf67e 100644 --- a/prefork/prefork.go +++ b/prefork/prefork.go @@ -2,12 +2,17 @@ package prefork import ( + "context" "errors" + "fmt" "log" "net" "os" "os/exec" + "os/signal" "runtime" + "sync" + "syscall" "time" "github....
[ "prefork/prefork.go" ]
[ { "comment": "Moving `sigCh <- procSig...` to before `OnChildSpawn` was already enough to make sure we don't leave any zombies. Adding this additional `Wait()` now makes each child Waited on twice, which is usually not advised to do.\n\nSee also: https://github.com/golang/go/blob/8594bf46218254ce5508e1500b92d43...
true
valyala/fasthttp
2,196
issue_to_patch
chore(deps): bump github.com/klauspost/compress from 1.18.5 to 1.18.6
Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.18.5 to 1.18.6. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/klauspost/compress/releases">github.com/klauspost/compress's releases</a>.</em></p> <blockquote> <h2>v1.18.6</h2> <h2>What's Chan...
d6a99db432025de9ae13051cb42b3e6c3d6568a3
ddfc810fb1605f363cbfac3533155ddc84843a24
diff --git a/go.mod b/go.mod index c17901f16a..e186f4828c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.1 require ( github.com/andybalholm/brotli v1.2.1 - github.com/klauspost/compress v1.18.5 + github.com/klauspost/compress v1.18.6 github.com/valyala/bytebufferpool v1.0.0 golang.org/x/cryp...
[ "go.mod", "go.sum" ]
[]
true
valyala/fasthttp
2,195
issue_to_patch
chore(deps): bump securego/gosec from 2.25.0 to 2.26.1
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.25.0 to 2.26.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/securego/gosec/releases">securego/gosec's releases</a>.</em></p> <blockquote> <h2>v2.26.1</h2> <h2>Changelog</h2> <ul> <li>4a3bd8af174872c778439083d...
f36c9009027f81f4fbf304822f96752517b08949
4c00b035ac6017327c1e017ada9502533ec64c19
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 3f0e6ec402..ae031a98ea 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -16,6 +16,6 @@ jobs: steps: - uses: actions/checkout@v6 - name: Run Gosec Security Scanner - uses: secur...
[ ".github/workflows/security.yml" ]
[]
true
valyala/fasthttp
2,190
issue_to_patch
header: match net/http CL+TE handling
Match net/http behavior when requests or responses contain both Content-Length and Transfer-Encoding. Parse and validate Content-Length even when Transfer-Encoding is present, so invalid lengths are rejected. For valid Content-Length with chunked Transfer-Encoding, keep chunked framing as authoritative. Also apply t...
0b4cede30fa0eb22f9d10999e23ebaabba15e107
9f18649b20dbc28601d5aad0f7b2cd6edb40598f
diff --git a/header.go b/header.go index eddeea9111..f59283dce8 100644 --- a/header.go +++ b/header.go @@ -206,14 +206,15 @@ func (h *ResponseHeader) ContentLength() int { // -2 means Transfer-Encoding: identity. func (h *RequestHeader) ContentLength() int { if h.disableSpecialHeader { - // Parse Content-Length fr...
[ "header.go", "header_test.go", "http_test.go", "server_test.go" ]
[]
diff --git a/header_test.go b/header_test.go index 9c9a560e0e..af790e5977 100644 --- a/header_test.go +++ b/header_test.go @@ -507,6 +507,16 @@ func TestRequestDisableSpecialHeaders(t *testing.T) { t.Fatalf("body content incorrect with DisableSpecialHeader: got %q, expected %q", string(req.Body()), testBody) }...
true
valyala/fasthttp
2,191
issue_to_patch
header: reject duplicate Content-Length in responses
Reject duplicate Content-Length headers when parsing response headers instead of accepting the last value. This prevents response framing disagreements with other HTTP/1.x parsers on reused connections. Add regression coverage for ResponseHeader.Read and Response.Read, including identical duplicate values and the al...
5c0d91a3da371237cfe826bd9c438492d091e3a9
28a47df12831cd496bd301474dd23f28342392c7
diff --git a/header.go b/header.go index 0937bb8d35..24cad96e2b 100644 --- a/header.go +++ b/header.go @@ -2989,6 +2989,8 @@ func (h *ResponseHeader) parseHeaders(buf []byte) (int, error) { // 'identity' content-length by default h.contentLength = -2 + contentLengthSeen := false + var s headerScanner s.b = bu...
[ "header.go", "header_test.go", "http_test.go" ]
[]
diff --git a/header_test.go b/header_test.go index 65dfd1ee5f..2d4c6963d1 100644 --- a/header_test.go +++ b/header_test.go @@ -3112,10 +3112,6 @@ func TestResponseHeaderReadSuccess(t *testing.T) { testResponseHeaderReadSuccess(t, h, "HTTP/1.1 400 OK\nconTEnt-leNGTH: 123\nConTENT-TYPE: ass\r\n\r\n", 400, 123, "ass"...
true
valyala/fasthttp
2,192
issue_to_patch
header: reject unsupported response Transfer-Encoding
Reject HTTP/1.1 response Transfer-Encoding values unless they are a single chunked header, matching net/http's strict transfer parser behavior. This prevents arbitrary or compound response Transfer-Encoding values from being silently normalized to chunked and avoids desync/body parsing ambiguity when parsing upstrea...
97b38d3a4884b7c3d8891750a4c752073bc3c152
aaf9cb1e107240cf4b290b0a1e7cbbe609966e0e
diff --git a/header.go b/header.go index 01512a1309..eddeea9111 100644 --- a/header.go +++ b/header.go @@ -2991,6 +2991,7 @@ func (h *ResponseHeader) parseHeaders(buf []byte) (int, error) { var s headerScanner s.b = buf var kv *argsKV + transferEncodingSeen := false for s.next() { // Trim trailing whitespa...
[ "header.go", "header_test.go", "http_test.go" ]
[]
diff --git a/header_test.go b/header_test.go index a7eb65cb0b..9c9a560e0e 100644 --- a/header_test.go +++ b/header_test.go @@ -3113,9 +3113,9 @@ func TestResponseHeaderReadSuccess(t *testing.T) { testResponseHeaderReadSuccess(t, h, "HTTP/1.1 300 OK\r\nContent-Type: foo/barr\r\nTransfer-Encoding: chunked\r\nContent-Le...
true
valyala/fasthttp
2,193
issue_to_patch
http: reject whitespace before chunk extensions
Reject space and tab between the chunk-size and chunk-extension separator while preserving net/http-compatible trailing OWS before CRLF. This avoids parser divergence for chunk lines such as "3 ;ext\r\n" without breaking the existing acceptance of padded chunk-size lines like "3 \r\n". Add parser regression coverage...
97b38d3a4884b7c3d8891750a4c752073bc3c152
7ed2af83978fc7b81569168e8401cc60d8b2b25f
diff --git a/http.go b/http.go index a3c3e02613..27b77da508 100644 --- a/http.go +++ b/http.go @@ -2750,6 +2750,7 @@ func parseChunkSize(r *bufio.Reader) (int, error) { return -1, err } inExt := false + afterSizeOWS := false for { c, err := r.ReadByte() if err != nil { @@ -2777,8 +2778,14 @@ func parseCh...
[ "http.go", "http_test.go" ]
[]
diff --git a/http_test.go b/http_test.go index 63cd67e89d..5e7f99a78e 100644 --- a/http_test.go +++ b/http_test.go @@ -2163,11 +2163,73 @@ func TestRequestChunkedWhitespace(t *testing.T) { rb := bufio.NewReader(r) err := req.Read(rb) if err != nil { - t.Fatalf("Unexpected error when reading chunked request: %v",...
true
valyala/fasthttp
2,175
issue_to_patch
feat: add ExpectHandler for richer Expect: 100-continue handling
ContinueHandler only returns a bool, limiting the server to either accepting (100) or rejecting with 417. ExpectHandler allows returning any HTTP status code, and closes the connection on rejection since the client may have already started sending body data per RFC 9110. ExpectHandler takes precedence when both hand...
534461ad123bfbcc1190d29cb3553a19b72d2845
7cb5746fa880821cfc17e3924856c5bb8356e21f
diff --git a/server.go b/server.go index 403e3eaced..0b8fc0b575 100644 --- a/server.go +++ b/server.go @@ -194,6 +194,26 @@ type Server struct { // like they are normal requests. ContinueHandler func(header *RequestHeader) bool + // ExpectHandler is called after receiving the Expect 100 Continue Header. + // + //...
[ "server.go", "server_test.go" ]
[ { "comment": "I can also see a case where someone would want to block this based on IP for example. One the one hand passing a `RequestCtx` instead would expose that kind of information. But it's weird to have a Reponse object on this then (unless that is then actually usable). What do you think?", "path": ...
diff --git a/server_test.go b/server_test.go index 0aa294506c..0d7c19b353 100644 --- a/server_test.go +++ b/server_test.go @@ -2102,6 +2102,225 @@ func TestServerContinueHandler(t *testing.T) { } } +func TestServerExpectHandler(t *testing.T) { + t.Parallel() + + acceptContentLength := 5 + s := &Server{ + ExpectHa...
true
valyala/fasthttp
2,175
comment_to_fix
feat: add ExpectHandler for richer Expect: 100-continue handling
I can also see a case where someone would want to block this based on IP for example. One the one hand passing a `RequestCtx` instead would expose that kind of information. But it's weird to have a Reponse object on this then (unless that is then actually usable). What do you think?
534461ad123bfbcc1190d29cb3553a19b72d2845
7cb5746fa880821cfc17e3924856c5bb8356e21f
diff --git a/server.go b/server.go index 403e3eaced..0b8fc0b575 100644 --- a/server.go +++ b/server.go @@ -194,6 +194,26 @@ type Server struct { // like they are normal requests. ContinueHandler func(header *RequestHeader) bool + // ExpectHandler is called after receiving the Expect 100 Continue Header. + // + //...
[ "server.go" ]
[ { "comment": "I can also see a case where someone would want to block this based on IP for example. One the one hand passing a `RequestCtx` instead would expose that kind of information. But it's weird to have a Reponse object on this then (unless that is then actually usable). What do you think?", "path": ...
true
valyala/fasthttp
2,175
comment_to_fix
feat: add ExpectHandler for richer Expect: 100-continue handling
```suggestion // or any other status code to reject it and close the connection since the // client may have already started sending the request body. ```
534461ad123bfbcc1190d29cb3553a19b72d2845
7cb5746fa880821cfc17e3924856c5bb8356e21f
diff --git a/server.go b/server.go index 403e3eaced..0b8fc0b575 100644 --- a/server.go +++ b/server.go @@ -194,6 +194,26 @@ type Server struct { // like they are normal requests. ContinueHandler func(header *RequestHeader) bool + // ExpectHandler is called after receiving the Expect 100 Continue Header. + // + //...
[ "server.go" ]
[ { "comment": "```suggestion\n\t// or any other status code to reject it and close the connection since the\n\t// client may have already started sending the request body.\n```", "path": "server.go", "hunk": "@@ -194,6 +194,29 @@ type Server struct {\n \t// like they are normal requests.\n \tContinueHand...
true
valyala/fasthttp
2,175
comment_to_fix
feat: add ExpectHandler for richer Expect: 100-continue handling
```suggestion // RemoteAddr for IP-based filtering). The response must not be modified. ``` This is not strictly true, so lets word it like this.
534461ad123bfbcc1190d29cb3553a19b72d2845
7cb5746fa880821cfc17e3924856c5bb8356e21f
diff --git a/server.go b/server.go index 403e3eaced..0b8fc0b575 100644 --- a/server.go +++ b/server.go @@ -194,6 +194,26 @@ type Server struct { // like they are normal requests. ContinueHandler func(header *RequestHeader) bool + // ExpectHandler is called after receiving the Expect 100 Continue Header. + // + //...
[ "server.go" ]
[ { "comment": "```suggestion\n\t// RemoteAddr for IP-based filtering). The response must not be modified.\n```\nThis is not strictly true, so lets word it like this.", "path": "server.go", "hunk": "@@ -194,6 +194,29 @@ type Server struct {\n \t// like they are normal requests.\n \tContinueHandler func(he...
true
valyala/fasthttp
2,185
issue_to_patch
Sanitize cookie setters to prevent CRLF injection
Prevent cookie APIs from serializing embedded CR or LF bytes into Cookie and Set-Cookie header lines. Route Cookie key, value, domain, and path setters, parsed cookie fields, and RequestHeader/ResponseHeader SetCookie paths through the existing newline sanitization. Sanitize paths after normalization so percent-deco...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
2f824ef759cd22eae3eea21608bcdc71e635c34a
diff --git a/cookie.go b/cookie.go index 134cb48810..83442083d9 100644 --- a/cookie.go +++ b/cookie.go @@ -162,12 +162,14 @@ func (c *Cookie) Path() []byte { func (c *Cookie) SetPath(path string) { c.bufK = append(c.bufK[:0], path...) c.path = normalizePath(c.path, c.bufK) + c.path = removeNewLines(c.path) } /...
[ "cookie.go", "cookie_test.go", "header.go", "header_test.go" ]
[]
diff --git a/cookie_test.go b/cookie_test.go index 0b5fb7d535..e49f495b88 100644 --- a/cookie_test.go +++ b/cookie_test.go @@ -15,6 +15,84 @@ func TestCookiePanic(t *testing.T) { } } +func TestCookieSettersSanitizeNewLines(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + set func(c *Co...
true
valyala/fasthttp
2,184
issue_to_patch
server: keep hijacked reader out of pool
When KeepHijackedConns is enabled, the hijacked connection may outlive the HijackHandler. The wrapper continues reading through the buffered reader after the handler returns, so returning that reader to the pool can let another connection reset it while the hijacked connection is still in use. Keep the buffered read...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
55e1c8595045a4473f10f80d4dd35490fb779de5
diff --git a/server.go b/server.go index e84c222975..12b2aa3ecd 100644 --- a/server.go +++ b/server.go @@ -2667,7 +2667,9 @@ func hijackConnHandler(ctx *RequestCtx, r io.Reader, c net.Conn, s *Server, h Hi hjc := s.acquireHijackConn(r, c) h(hjc) - if br, ok := r.(*bufio.Reader); ok { + // When the caller keeps us...
[ "server.go", "server_test.go" ]
[]
diff --git a/server_test.go b/server_test.go index 25da478519..e0e585a637 100644 --- a/server_test.go +++ b/server_test.go @@ -2925,6 +2925,51 @@ func TestRequestCtxHijackReduceMemoryUsage(t *testing.T) { }) } +func TestRequestCtxHijackKeepHijackedConnsKeepsReaderOutOfPool(t *testing.T) { + t.Parallel() + + s := &...
true
valyala/fasthttp
2,186
issue_to_patch
Sanitize redirect Location header to prevent CRLF injection
Route RequestCtx.Redirect Location updates through the canonical response header setter so CR and LF bytes are normalized before serialization. Add regression coverage for query-only and fragment-only redirects containing CRLF, and verify the serialized response cannot emit an injected header line.
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
814dcab74eab80509dacd03711d0cdbfec515c55
diff --git a/server.go b/server.go index e84c222975..b3c24d7563 100644 --- a/server.go +++ b/server.go @@ -1450,7 +1450,7 @@ func (ctx *RequestCtx) RedirectBytes(uri []byte, statusCode int) { } func (ctx *RequestCtx) redirect(uri []byte, statusCode int) { - ctx.Response.Header.setNonSpecial(strLocation, uri) + ctx....
[ "server.go", "server_test.go" ]
[]
diff --git a/server_test.go b/server_test.go index 25da478519..094e5579d9 100644 --- a/server_test.go +++ b/server_test.go @@ -567,12 +567,14 @@ func TestRequestCtxRedirect(t *testing.T) { testRequestCtxRedirect(t, "http://qqq/foo/bar?baz=111", "#aaa", "http://qqq/foo/bar?baz=111#aaa") testRequestCtxRedirect(t, "ht...
true
valyala/fasthttp
2,187
issue_to_patch
header: reject pre-colon whitespace in request headers
Reject request header field names with whitespace immediately before the colon instead of trimming them before special-header handling. This prevents parser differentials for malformed framing and routing headers such as Content-Length, Transfer-Encoding, and Host when a frontend forwards raw invalid request headers...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
d5c79292c03d3d84aef7e0578efd594e97843474
diff --git a/header.go b/header.go index 2cacf0fe7f..dfc403bdf3 100644 --- a/header.go +++ b/header.go @@ -3113,9 +3113,12 @@ func (h *RequestHeader) parseHeaders(buf []byte) (int, error) { s.b = buf for s.next() { - // Trim trailing whitespace before the colon to normalize headers - // like "Content-Length :" ...
[ "header.go", "header_test.go", "http_test.go" ]
[]
diff --git a/header_test.go b/header_test.go index c17abb988b..63f708c6a4 100644 --- a/header_test.go +++ b/header_test.go @@ -3273,6 +3273,12 @@ func TestRequestHeaderReadError(t *testing.T) { // Space before header name testRequestHeaderReadError(t, h, "G(ET /foo/bar HTTP/1.1\r\n foo: bar\r\n\r\n") + // Whitesp...
true
valyala/fasthttp
2,188
issue_to_patch
header: reject invalid trailer names
Validate trailer names added through AddTrailerBytes before storing them for Trailer header serialization. Trim OWS around comma-separated trailer names, reject names containing bytes outside the HTTP field-name token set, and keep the existing forbidden-trailer filtering in place. This prevents CRLF injection throu...
1f00bc7c2857fb7b48b6e52009b0e571a5424f1a
209fa4b5c4c850917f7739f73f7f9ac7b1f08abf
diff --git a/header.go b/header.go index 2cacf0fe7f..3ce592353b 100644 --- a/header.go +++ b/header.go @@ -505,20 +505,14 @@ func (h *header) AddTrailerBytes(trailer []byte) (err error) { if i < 0 { i = len(trailer) } - key := trailer[:i] - for len(key) > 0 && key[0] == ' ' { - key = key[1:] - } - for l...
[ "header.go", "header_test.go" ]
[]
diff --git a/header_test.go b/header_test.go index c17abb988b..19040c4034 100644 --- a/header_test.go +++ b/header_test.go @@ -2017,7 +2017,7 @@ func TestResponseHeaderAddTrailerError(t *testing.T) { var h ResponseHeader err := h.AddTrailer("Foo, Content-Length , bAr,Transfer-Encoding, uSer aGent") - expectedTr...
true
valyala/fasthttp
2,183
issue_to_patch
server: apply ReadTimeout before first byte with ReduceMemoryUsage
On new connections with ReduceMemoryUsage enabled, serveConn could reach acquireByteReader before installing a read deadline. That left the first blocking read outside ReadTimeout and allowed silent clients to keep the connection open until some external timeout closed it. Apply ReadTimeout before the first read on ...
c2e2a6c3e5c6664ccf154019f47b3187f9404893
f69b27100cfa347eebf7594e94577dd6b0fab175
diff --git a/server.go b/server.go index 403e3eaced..e84c222975 100644 --- a/server.go +++ b/server.go @@ -2290,8 +2290,15 @@ func (s *Server) serveConn(c net.Conn) error { for { connRequestNum++ - // If this is a keep-alive connection set the idle timeout. - if connRequestNum > 1 { + if connRequestNum == 1 {...
[ "server.go", "server_test.go" ]
[]
diff --git a/server_test.go b/server_test.go index 0aa294506c..25da478519 100644 --- a/server_test.go +++ b/server_test.go @@ -1215,6 +1215,53 @@ func TestServerTLSReadTimeout(t *testing.T) { } } +func TestServerReduceMemoryUsageReadTimeoutOnFirstByte(t *testing.T) { + t.Parallel() + + s := &Server{ + Handler: fu...
true
valyala/fasthttp
2,182
issue_to_patch
Sanitize first-line header setters to prevent CRLF injection
Prevent request and response first-line setters from serializing embedded CR or LF bytes into the start line. Route SetMethod, SetRequestURI, SetProtocol, and SetStatusMessage through the existing newline sanitization used by other header-value setters. This preserves behavior for valid inputs while preventing heade...
534461ad123bfbcc1190d29cb3553a19b72d2845
6f17f23c3c25d38484d582c109d9763363a49e3d
diff --git a/header.go b/header.go index f3fc0e5d87..2cacf0fe7f 100644 --- a/header.go +++ b/header.go @@ -143,12 +143,12 @@ func (h *ResponseHeader) StatusMessage() []byte { // SetStatusMessage sets response status message bytes. func (h *ResponseHeader) SetStatusMessage(statusMessage []byte) { - h.statusMessage =...
[ "client_test.go", "header.go", "header_test.go" ]
[]
diff --git a/client_test.go b/client_test.go index af45b99f62..5f68a622ed 100644 --- a/client_test.go +++ b/client_test.go @@ -273,14 +273,89 @@ func TestClientInvalidURI(t *testing.T) { req.Header.SetMethod(MethodGet) req.SetRequestURI("http://example.com\r\n\r\nGET /\r\n\r\n") err := c.Do(req, res) - if err == ...
true
valyala/fasthttp
2,181
issue_to_patch
Match net/http sensitive header redirect policy
Strip sensitive headers in DoRedirects matching net/http's redirect policy. Reported by @vnykmshr
534461ad123bfbcc1190d29cb3553a19b72d2845
a06950328bf75033df548f76cd3e02ba9e2e0d6a
diff --git a/client.go b/client.go index 6d16696def..30d43f5ca3 100644 --- a/client.go +++ b/client.go @@ -1143,6 +1143,7 @@ func doRequestFollowRedirects( req *Request, resp *Response, url string, maxRedirectsCount int, c clientDoer, ) (statusCode int, body []byte, err error) { redirectsCount := 0 + initialHost :...
[ "client.go", "client_test.go", "headers.go" ]
[]
diff --git a/client_test.go b/client_test.go index af45b99f62..893a61cc37 100644 --- a/client_test.go +++ b/client_test.go @@ -1761,6 +1761,73 @@ func TestClientFollowRedirects(t *testing.T) { ReleaseResponse(resp) } +func TestShouldStripSensitiveHeadersOnRedirect(t *testing.T) { + t.Parallel() + + testCases := []...
true
varvet/pundit
874
issue_to_patch
update documentation on overriding authorize for namespaced policies The [docs](https://github.com/varvet/pundit/#policy-namespacing) recommend overriding the `authorize` helper for controllers using namespaced policies like so: ```ruby def authorize(record, query = nil) super([:admin, record], query) end ```...
Update README recommendation around namespacing
Fixes #859. Also did a drive-by on the user context by using Data from Ruby 3.2. ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individual commits are me...
977686e6ec900fe93a8f1cc782c381fbef0a017c
16603b67495802b91a30f7c41dba85f8e257f2c8
diff --git a/README.md b/README.md index f11e4558..ed9478e4 100644 --- a/README.md +++ b/README.md @@ -170,11 +170,6 @@ Controller: def show @user = authorize User.find(params[:id]) end - -# return the record even for namespaced policies -def show - @user = authorize [:admin, User.find(params[:id])] -end ``` ...
[ "README.md" ]
[]
true
varvet/pundit
873
issue_to_patch
RSpec 4 compatibility Hello! **Describe the bug** It seems that the [pundit RSpec integration](https://github.com/varvet/pundit?tab=readme-ov-file#rspec) is not compatible with RSpec 4, which seems to be coming soon. They've cut a beta release and [seem to be preparing for the full release](https://github.com/rspec/...
Update pundit/rspec for rspec 4-compatibility
- **rspec 4 has changed filter matching from ANY to ALL** (fixes #872) - **rspec 4 has dropped global patching and should** (fixes test suite under rspec 4) ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted r...
d53c8414e4c1a096585a036ea7c1ac1b22dac417
50523ce0127ddd5bb4b3c10e62f5cd50d1330236
diff --git a/CHANGELOG.md b/CHANGELOG.md index fdf8260d..fa271bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Add support for `params.expect` using `expected_parameters` and `expected_parameters_for`. [#855](https://github.com/varvet/pundit/pull/855) +### Fixed +- Update for rspec 4 breaking cha...
[ "CHANGELOG.md", "README.md", "Rakefile", "lib/pundit/rspec.rb", "spec/authorization_spec.rb", "spec/policies/post_policy_spec.rb", "spec/rspec_dsl_spec.rb" ]
[]
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index 980353df..cc8466e7 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" require "action_controller" -describe Pundit::Authorization do +RSpec.describe Pundit::Authorization do def ...
true
varvet/pundit
855
issue_to_patch
Support new params `expect` method to permit parameters In Rails 8 the method `expect` has been introduced to mitigate some issues with the current `params.require(:foo).permit(:bar)` approach. One issue with the current approach is that if someone sends unexpected data, say `POST { foo: "bam" }` the Rails app will cr...
Add support for params.expect
Fixes: https://github.com/varvet/pundit/issues/841 ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individual commits are meaningful. - [x] I have ...
7aa30eb9fb71003d017e96f411cfa743286f29b0
c6b7b259f4137f90891b444d3e0643cec4a2bc15
diff --git a/CHANGELOG.md b/CHANGELOG.md index b667119f..fdf8260d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Add support for `params.expect` using `expected_parameters` and `expected_parameters_for`. [#855](https://github.com/varvet/pundit/pull/855) + ## 2.5.2 (2025-09-24) ##...
[ "CHANGELOG.md", "README.md", "lib/pundit/authorization.rb", "spec/authorization_spec.rb", "spec/support/policies/post_policy.rb" ]
[ { "comment": "Looks like JRUBY doesn't support this version? I don't know if this is a good approach though :)", "path": "spec/authorization_spec.rb", "hunk": "@@ -273,6 +273,91 @@ def to_params(*args, **kwargs, &block)\n end\n end\n \n+ if Gem::Version.new(ActionPack::VERSION::STRING) >= Gem::Ve...
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index f7a595a2..980353df 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "spec_helper" -require "action_controller/metal/strong_parameters" +require "action_controller"...
true
varvet/pundit
855
comment_to_fix
Add support for params.expect
Looks like JRUBY doesn't support this version? I don't know if this is a good approach though :)
7aa30eb9fb71003d017e96f411cfa743286f29b0
c6b7b259f4137f90891b444d3e0643cec4a2bc15
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index f7a595a2..980353df 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "spec_helper" -require "action_controller/metal/strong_parameters" +require "action_controller"...
[ "spec/authorization_spec.rb" ]
[ { "comment": "Looks like JRUBY doesn't support this version? I don't know if this is a good approach though :)", "path": "spec/authorization_spec.rb", "hunk": "@@ -273,6 +273,91 @@ def to_params(*args, **kwargs, &block)\n end\n end\n \n+ if Gem::Version.new(ActionPack::VERSION::STRING) >= Gem::Ve...
true
varvet/pundit
870
issue_to_patch
JRuby 9.3 is EOL, so we move to 9.4
https://github.com/jruby/jruby/wiki/Roadmap
3488802b2f218ba26562e91186655297c95eb6da
de12578462ca95d01ab4626d5b2368a96a54d70a
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d213a074..ac775022 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,14 +9,6 @@ on: permissions: contents: read -env: - # `github.ref` points to the *merge commit* when running tests on a pull request, which w...
[ ".github/workflows/main.yml", ".rubocop.yml", ".standard.yml", "Gemfile", "README.md", "lib/pundit.rb", "lib/pundit/error.rb", "lib/pundit/rspec.rb", "pundit.gemspec", "spec/authorization_spec.rb", "spec/generators_spec.rb", "spec/pundit_spec.rb", "spec/rspec_dsl_spec.rb", "spec/simple_cov...
[]
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index 5bc1d255..f7a595a2 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -231,7 +231,7 @@ def to_params(*args, **kwargs, &block) end it "goes through the policy cache" do - params = to_params(post: { title:...
true
varvet/pundit
869
issue_to_patch
Add Ruby 4.0 to matrix
https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/
2d665d67a26f794987df926e49676948fe115289
85537ea84e22d1c4ed1032d7934af53c7d5954aa
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8d9c7e7..d213a074 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: - "3.2" - "3.3" - "3.4" + - "4.0" - "jruby-9.3.15" - "jruby" ...
[ ".github/workflows/main.yml" ]
[]
true
varvet/pundit
867
issue_to_patch
Bump to v2.5.2
## To do - [x] Make changes: - [x] Bump `Pundit::VERSION` in `lib/pundit/version.rb`. - [x] Update `CHANGELOG.md`. - [x] Open pull request 🚀 and merge it. - [x] Run [push gem](https://github.com/varvet/pundit/actions/workflows/push_gem.yml) GitHub Action. - [x] Make an announcement in [Pundit discussions](https:/...
674abac197c7ecc000fd25a4542344d38c998535
7ff48a83790aef27bd89fa4da6a0a238599bca2d
diff --git a/CHANGELOG.md b/CHANGELOG.md index 54282e46..b667119f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +## 2.5.2 (2025-09-24) + ### Fixed - Added `config/rubocop-rspec.yml` back from accidentally being excluded [#866](https://github.com/varvet/pundit/issues/866) diff --git...
[ "CHANGELOG.md", "lib/pundit/version.rb" ]
[]
true
varvet/pundit
866
issue_to_patch
Pundit 2.5.1 distribution missing file config/rubocop-rspec.yml **Describe the bug** The 2.5.1 distribution does not include file `config/rubocop-rspec.yml` **To Reproduce** - `gem fetch pundit --version 2.5.1` - `gem unpack pundit-2.5.1.gem` Observe that `pundit-2.5.1/config/rubocop-rspec.yml` does not exist. **Ex...
Add rubocop config file back to gem release files
Closes #865 We changed which files are included in the gem recently, this was done to modernize our gemspec along with what `bundle gem` generated. `bundle gem mygem --exe --coc --changelog --github-username=burgestrand --mit --test=rspec --ci=github --linter=standard` ```ruby spec.files = Dir.chdir(__dir__) do ...
27a840bedadf0ef3d66f1857edd966c2e01cc18e
923eebf39ccd6f8095a5c4270953e7a19d6d16a6
diff --git a/CHANGELOG.md b/CHANGELOG.md index e2148513..54282e46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixed +- Added `config/rubocop-rspec.yml` back from accidentally being excluded [#866](https://github.com/varvet/pundit/issues/866) + ## 2.5.1 (2025-09-12) ### Fixed...
[ "CHANGELOG.md", "pundit.gemspec" ]
[]
true
varvet/pundit
852
issue_to_patch
Exclude unwanted files from packaged gem
There's no need to ship test files, rubocop configs, etc. ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individual commits are meaningful. - ~~I have add...
be91242e4faed5d07bb78f8496d6c69cc76c5196
beaf029f0eaa020b9883728794942e0b6dda4cff
diff --git a/pundit.gemspec b/pundit.gemspec index 6a9dd01b..0a52f1be 100644 --- a/pundit.gemspec +++ b/pundit.gemspec @@ -14,11 +14,14 @@ Gem::Specification.new do |gem| gem.homepage = "https://github.com/varvet/pundit" gem.license = "MIT" - gem.files = `git ls-files`.split($INPUT_RECORD_SE...
[ "pundit.gemspec" ]
[]
true
varvet/pundit
862
issue_to_patch
Release v2.5.1
## To do - [x] Make changes: - [x] Bump `Pundit::VERSION` in `lib/pundit/version.rb`. - [x] Update `CHANGELOG.md`. - [x] Open pull request 🚀 and merge it. - [x] Run [push gem](https://github.com/varvet/pundit/actions/workflows/push_gem.yml) GitHub Action. - [x] Make an announcement in [Pundit discussions](https:/...
a45734349b075d67089c27e1e96dc2fa4477e4bc
6ceca0d2ab84d2240e6422e7b14d208ad10e3304
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 236f628d..dabc94a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,12 +10,10 @@ permissions: contents: read env: - CC_TEST_REPORTER_ID: "ac477089fe20ab4fc7e0d304cab75f72d73d58a7596d366935d18fcc7d51f8f9" - ...
[ ".github/workflows/main.yml", ".gitignore", "CHANGELOG.md", "README.md", "bin/console", "bin/setup", "lib/pundit/version.rb", "pundit.gemspec" ]
[]
true
varvet/pundit
863
issue_to_patch
Update build matrix for Ruby 3.4/3.1(EOL)
4bb6a67819572bd9431d30048fbab4c9685cfbf2
381b202dd2e11c5eb0ea1134d29f85331a01d643
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dabc94a0..f8d9c7e7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,9 +25,9 @@ jobs: fail-fast: false matrix: ruby-version: - - "3.1" - "3.2" - "3.3" + ...
[ ".github/workflows/main.yml" ]
[]
true
varvet/pundit
858
issue_to_patch
Update inline code documentation
- **Move constants out of pundit.rb into conventional location** - **Add version tags to each constant and method** ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made ...
f5095b49f22f4d795ccfcc46b75025c742d15a98
432160a4f9f080722793b1882c9628ea658dd5da
diff --git a/lib/pundit.rb b/lib/pundit.rb index 4cf9bbca..4fa1309d 100644 --- a/lib/pundit.rb +++ b/lib/pundit.rb @@ -3,83 +3,30 @@ require "active_support" require "pundit/version" +require "pundit/error" require "pundit/policy_finder" -require "pundit/authorization" require "pundit/context" +require "pundit/au...
[ "lib/pundit.rb", "lib/pundit/authorization.rb", "lib/pundit/cache_store.rb", "lib/pundit/cache_store/legacy_store.rb", "lib/pundit/cache_store/null_store.rb", "lib/pundit/context.rb", "lib/pundit/error.rb", "lib/pundit/helper.rb", "lib/pundit/policy_finder.rb", "lib/pundit/railtie.rb", "lib/pund...
[]
true
varvet/pundit
857
issue_to_patch
Fix error raised when requiring pundit/rspec before active support
Fix regression from #837 ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individual commits are meaningful. - [x] I have added relevant lines to the CHANGE...
7a8aa4aa901aca84e356cae2920120d37243d69d
e4f74eb7a2bb8a832abae7279c275cbfab6d6a8a
diff --git a/CHANGELOG.md b/CHANGELOG.md index 85be9d08..c3695984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixed +- Requiring only `pundit/rspec` can raise an error in Active Support (#857) + ## 2.5.0 (2025-03-03) ### Added diff --git a/lib/pundit/rspec.rb b/lib/pundit/rs...
[ "CHANGELOG.md", "lib/pundit/rspec.rb" ]
[]
true
varvet/pundit
837
issue_to_patch
Modernize the `active_support` requires
We were kind of doing it wrong, and it worked in tests by accident because we required railties and actionpack. ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have ma...
2b0ca28bd2b0f0fe46155b2561903146c57513bb
2eb359eacee0ba0e4820376c852b605301ea3b77
diff --git a/CHANGELOG.md b/CHANGELOG.md index d83e138e..31eac5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## Changed - Deprecated `Pundit::SUFFIX`, moved it to `Pundit::PolicyFinder::SUFFIX` (#835) +- Explicitly require less of `active_support` (#837) ## 2.4.0 (2024-08-26) diff --git a/lib...
[ "CHANGELOG.md", "lib/pundit.rb", "lib/pundit/policy_finder.rb", "lib/pundit/rspec.rb", "pundit.gemspec", "spec/authorization_spec.rb", "spec/spec_helper.rb", "spec/support/models/customer/post.rb" ]
[]
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index 8bfa3fcb..ca291f9a 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "spec_helper" +require "action_controller/metal/strong_parameters" describe Pundit::Authoriz...
true
varvet/pundit
851
issue_to_patch
Wrong generator template suffix **Describe the bug** A clear and concise description of what the bug is. Currently the generator template suffix of the `pundit` gem is `.rb` instead of `.tt`. This cause some IDEs like RubyMine generates the wrong inspection message if there is a class with the same `ApplicationPolicy...
Release v2.5.0
## To do - [x] Make changes: - [x] Bump `Pundit::VERSION` in `lib/pundit/version.rb`. - [x] Update `CHANGELOG.md`. - [x] Open pull request 🚀 and merge it. - [x] Run [push gem](https://github.com/varvet/pundit/actions/workflows/push_gem.yml) GitHub Action. - [x] Make an announcement in [Pundit discussions](...
51ce6a964cb5b9426263dc562312bdb854e22d8e
37f80995f582fbb436a5f5f841717236e82e6443
diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd4be54..85be9d08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,60 +2,62 @@ ## Unreleased -## Added +## 2.5.0 (2025-03-03) -- Add `Pundit::Authorization#pundit_reset!` hook to reset the policy and policy scope cache. (#830) -- Add links to gemspec. (#845) -- R...
[ "CHANGELOG.md", "lib/pundit/version.rb" ]
[]
true
varvet/pundit
850
issue_to_patch
Add documentation to provide a guide for how to use pundit with rails 8's built-in authentication generator
Please disregard if this is not a necessary update on the documentation. I was testing the combination of pundit and the new rails 8 authentication generator. If you use the built in authentication generator, you would get the currently authenticated user via `Current.user` not `current_user`. Since pundit expect `cur...
55074301a35dbafc65387816ee1f3d68997bf0d4
b117d412f95aa9d26b533a73b39df22f8449d5b8
diff --git a/CHANGELOG.md b/CHANGELOG.md index 353f5e97..fdd4be54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add `Pundit::Authorization#pundit_reset!` hook to reset the policy and policy scope cache. (#830) - Add links to gemspec. (#845) - Register policies directories for Rails 8 code statistics...
[ "CHANGELOG.md", "README.md" ]
[]
true
varvet/pundit
833
issue_to_patch
Register policies directories for Rails 8 code statistics
This PR add a `Rails::Railtie` to `Pundit` for configure the new [stats directories](https://edgeapi.rubyonrails.org/classes/Rails/CodeStatistics.html) in upcomming Rails 8.
cbaa0ab8979d17bf36399127241ac2d6d81f0bf8
8dfc38f16d3811385347e38dbaaf78cb9cb92cf9
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ba84800..353f5e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Add `Pundit::Authorization#pundit_reset!` hook to reset the policy and policy scope cache. (#830) - Add links to gemspec. (#845) +- Register policies directories for Rails 8 code statisti...
[ "CHANGELOG.md", "lib/pundit.rb", "lib/pundit/railtie.rb" ]
[ { "comment": "A _tiny_ nitpick, it seems the documentation you linked to has _singular_ for this, e.g. `Models` and `Model tests`.", "path": "lib/pundit/railtie.rb", "hunk": "@@ -0,0 +1,21 @@\n+# frozen_string_literal: true\n+\n+module Pundit\n+ class Railtie < Rails::Railtie\n+ if Rails.version.to_...
true
varvet/pundit
833
comment_to_fix
Register policies directories for Rails 8 code statistics
A _tiny_ nitpick, it seems the documentation you linked to has _singular_ for this, e.g. `Models` and `Model tests`.
cbaa0ab8979d17bf36399127241ac2d6d81f0bf8
8dfc38f16d3811385347e38dbaaf78cb9cb92cf9
diff --git a/lib/pundit/railtie.rb b/lib/pundit/railtie.rb new file mode 100644 index 00000000..30ba1631 --- /dev/null +++ b/lib/pundit/railtie.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Pundit + class Railtie < Rails::Railtie + if Rails.version.to_f >= 8.0 + initializer "pundit.stats_directo...
[ "lib/pundit/railtie.rb" ]
[ { "comment": "A _tiny_ nitpick, it seems the documentation you linked to has _singular_ for this, e.g. `Models` and `Model tests`.", "path": "lib/pundit/railtie.rb", "hunk": "@@ -0,0 +1,21 @@\n+# frozen_string_literal: true\n+\n+module Pundit\n+ class Railtie < Rails::Railtie\n+ if Rails.version.to_...
true
varvet/pundit
845
issue_to_patch
Link to changelog in gemspec
A well-kept changelog should be showcased! Could alternatively indent everything a little further and add a few of these; whatever your preference ```ruby gem.metadata["key"] = "value" ``` ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added...
d60d6f40d9420cd81383c5e9155aeddb30b8e8a6
719d81f8ba499786f2bdb00e97281ce14cc25730
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eca01570..236f628d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,6 +86,7 @@ jobs: coverage-check: permissions: + contents: read checks: write needs: test runs-on: ubuntu-latest di...
[ ".github/workflows/main.yml", ".rubocop.yml", ".rubocop_ignore_git.yml", "CHANGELOG.md", "Gemfile", "pundit.gemspec" ]
[]
true
varvet/pundit
848
issue_to_patch
Fix CI for JRuby broken on main due to outside influence
Found breaking build when https://github.com/varvet/pundit/pull/845 was opened.
a82833be46394ce4e3bb0c07a20d90fed03d1e50
33644b78961cd4daa122c46365d23843ba1bca19
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eec2515b..eca01570 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: - "3.1" - "3.2" - "3.3" - - "jruby-9.3.10" # oldest supported jruby + - "jruby...
[ ".github/workflows/main.yml", "Gemfile", "spec/spec_helper.rb", "spec/support/lib/controller.rb" ]
[]
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4b932571..3eb4bad4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,9 @@ end end +# @see https://github.com/rails/rails/issues/54260 +require "logger" if RUBY_ENGINE == "jruby" && RUBY_ENGINE_VERSION.start_with?("9.3") + require ...
true
varvet/pundit
842
issue_to_patch
Janitorial: Add documentation to most things
## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individual commits are meaningful. - [x] I have added relevant lines to the CHANGELOG. PS: Thank yo...
54cc64e45a3e4c606f555f05ce740e72c4f00946
3cbe44ff2bfe2f9dd0dee86725522fd8979417e9
diff --git a/Rakefile b/Rakefile index 7d829d9a..510c2129 100644 --- a/Rakefile +++ b/Rakefile @@ -15,6 +15,7 @@ end YARD::Rake::YardocTask.new do |t| t.files = ["lib/**/*.rb"] + t.stats_options = ["--list-undoc"] end task default: :spec diff --git a/lib/generators/rspec/policy_generator.rb b/lib/generators/...
[ "Rakefile", "lib/generators/rspec/policy_generator.rb", "lib/generators/test_unit/policy_generator.rb", "lib/pundit.rb", "lib/pundit/authorization.rb", "lib/pundit/cache_store.rb", "lib/pundit/cache_store/legacy_store.rb", "lib/pundit/cache_store/null_store.rb", "lib/pundit/context.rb", "lib/pundi...
[]
diff --git a/lib/generators/test_unit/policy_generator.rb b/lib/generators/test_unit/policy_generator.rb index cd0175a0..5a105796 100644 --- a/lib/generators/test_unit/policy_generator.rb +++ b/lib/generators/test_unit/policy_generator.rb @@ -4,6 +4,7 @@ module TestUnit # @private module Generators + # @priva...
true
varvet/pundit
830
issue_to_patch
Pundit caching isn't sensitive to current user changing @Burgestrand Hi there! Firstly, thanks for all the hard work maintaining pundit, it's a brilliant gem and I'm a long time fan. Re https://github.com/varvet/pundit/pull/797 > This should be backwards-compatible, so let me know if this breaks anything. Unf...
add hook for clear pundit context
Fix https://github.com/varvet/pundit/issues/811 As far as I can see, the caches are not being cleared after a `UserContext` change. Therefore, policies are being performed using the old UserContext. I would like to implement a simple solution to this issue. With this solution, caches can be cleared when deemed neces...
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/CHANGELOG.md b/CHANGELOG.md index 63415401..d3102949 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## Added + +- Add `Pundit::Authorization#pundit_reset!` hook to reset the policy and policy scope cache. (#830) + ## Changed - Deprecated `Pundit::SUFFIX`, moved it to ...
[ "CHANGELOG.md", "README.md", "lib/pundit/authorization.rb", "spec/authorization_spec.rb", "spec/support/lib/controller.rb", "spec/support/models/dummy_current_user.rb", "spec/support/policies/dummy_current_user_policy.rb" ]
[ { "comment": "I believe this should explain the purpose of this method, the concept of \"Pundit context\" isn't well-established enough to refer to.\r\n\r\nMore specifically it might be helpful to know _why_ one would call this. It might be prudent to specifically call out \"when you change the `current_user`\"...
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index ca291f9a..5bc1d255 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -9,7 +9,7 @@ def to_params(*args, **kwargs, &block) end let(:controller) { Controller.new(user, "update", to_params({})) } - let(:user) { dou...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
I believe this should explain the purpose of this method, the concept of "Pundit context" isn't well-established enough to refer to. More specifically it might be helpful to know _why_ one would call this. It might be prudent to specifically call out "when you change the `current_user`", and maybe the caches clearin...
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/lib/pundit/authorization.rb b/lib/pundit/authorization.rb index c0a77834..2e57cff8 100644 --- a/lib/pundit/authorization.rb +++ b/lib/pundit/authorization.rb @@ -40,12 +40,33 @@ def pundit # Hook method which allows customizing which user is passed to policies and # scopes initialized by {#author...
[ "lib/pundit/authorization.rb" ]
[ { "comment": "I believe this should explain the purpose of this method, the concept of \"Pundit context\" isn't well-established enough to refer to.\r\n\r\nMore specifically it might be helpful to know _why_ one would call this. It might be prudent to specifically call out \"when you change the `current_user`\"...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
This is something I missed my last review. Apologies! I think the spirit of this test is good, it captures the intent. I believe it's worth adding one more test an abstraction level above it, to capture the very important property that _authorize_ itself also resets. However, `#user` is kinda unofficially public ...
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index ca291f9a..5bc1d255 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -9,7 +9,7 @@ def to_params(*args, **kwargs, &block) end let(:controller) { Controller.new(user, "update", to_params({})) } - let(:user) { dou...
[ "spec/authorization_spec.rb" ]
[ { "comment": "This is something I missed my last review. Apologies!\r\n\r\nI think the spirit of this test is good, it captures the intent. I believe it's worth adding one more test an abstraction level above it, to capture the very important property that _authorize_ itself also resets.\r\n\r\nHowever, `#user`...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
I understand how this assertion ended up in this test, but I believe it's out of place. `pundit_policy_authorized?` (and `pundit_policy_scoped?`) doesn't have anything to do with the cache, it's a flag set by `authorize` to help catch errors in development: https://github.com/varvet/pundit?tab=readme-ov-file#ensurin...
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index ca291f9a..5bc1d255 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -9,7 +9,7 @@ def to_params(*args, **kwargs, &block) end let(:controller) { Controller.new(user, "update", to_params({})) } - let(:user) { dou...
[ "spec/authorization_spec.rb" ]
[ { "comment": "I understand how this assertion ended up in this test, but I believe it's out of place.\r\n\r\n`pundit_policy_authorized?` (and `pundit_policy_scoped?`) doesn't have anything to do with the cache, it's a flag set by `authorize` to help catch errors in development: https://github.com/varvet/pundit?...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
I missed this, but perhaps this should also specifically mention _user switching_ and not _context_.
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/README.md b/README.md index a1b59868..8c013798 100644 --- a/README.md +++ b/README.md @@ -582,6 +582,25 @@ def pundit_user User.find_by_other_means end ``` +### Handling User Switching in Pundit + +When switching users in your application, it's important to reset the Pundit user context to ensure that...
[ "README.md" ]
[ { "comment": "I missed this, but perhaps this should also specifically mention _user switching_ and not _context_.", "path": "README.md", "hunk": "@@ -660,6 +660,24 @@ class ApplicationController\n end\n ```\n \n+If you need to change the context for any reason, you will need to clear the caches stored ...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
Missed this method name change 🙂
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/README.md b/README.md index a1b59868..8c013798 100644 --- a/README.md +++ b/README.md @@ -582,6 +582,25 @@ def pundit_user User.find_by_other_means end ``` +### Handling User Switching in Pundit + +When switching users in your application, it's important to reset the Pundit user context to ensure that...
[ "README.md" ]
[ { "comment": "Missed this method name change 🙂 ", "path": "README.md", "hunk": "@@ -660,20 +660,20 @@ class ApplicationController\n end\n ```\n \n-If you need to change the context for any reason, you will need to clear the caches stored in the context. You can use the hook below to do this.\n+If you n...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
This code doesn't exercise `policy_scope`, more specifically it doesn't exercise that it clears the cache to make sure it picks up the new user. I looked through our tests and it doesn't seem like we have a scope that has different return values based on the `user` passed in. Might be necessary to create one to be a...
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/spec/authorization_spec.rb b/spec/authorization_spec.rb index ca291f9a..5bc1d255 100644 --- a/spec/authorization_spec.rb +++ b/spec/authorization_spec.rb @@ -9,7 +9,7 @@ def to_params(*args, **kwargs, &block) end let(:controller) { Controller.new(user, "update", to_params({})) } - let(:user) { dou...
[ "spec/authorization_spec.rb" ]
[ { "comment": "This code doesn't exercise `policy_scope`, more specifically it doesn't exercise that it clears the cache to make sure it picks up the new user.\r\n\r\nI looked through our tests and it doesn't seem like we have a scope that has different return values based on the `user` passed in. Might be neces...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
Nice catch on the new docs!
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/lib/pundit/authorization.rb b/lib/pundit/authorization.rb index c0a77834..2e57cff8 100644 --- a/lib/pundit/authorization.rb +++ b/lib/pundit/authorization.rb @@ -40,12 +40,33 @@ def pundit # Hook method which allows customizing which user is passed to policies and # scopes initialized by {#author...
[ "lib/pundit/authorization.rb" ]
[ { "comment": "Nice catch on the new docs!", "path": "lib/pundit/authorization.rb", "hunk": "@@ -218,6 +218,8 @@ def pundit_params_for(record)\n \n # @!endgroup\n \n+ # @!group Customize Pundit user", "resolving_sha": "ddaa1e6ee822e7249541e6de2ec79ad4b7f55570", "resolving_diff": "diff --gi...
true
varvet/pundit
830
comment_to_fix
add hook for clear pundit context
```suggestion def switch_user_to(user) terminate_session if authenticated? start_new_session_for user pundit_reset! # Ensure that the Pundit context is reset for the new user end ```
82f635c51a189216acb3d3cc7c40cd489fef5631
ddaa1e6ee822e7249541e6de2ec79ad4b7f55570
diff --git a/README.md b/README.md index a1b59868..8c013798 100644 --- a/README.md +++ b/README.md @@ -582,6 +582,25 @@ def pundit_user User.find_by_other_means end ``` +### Handling User Switching in Pundit + +When switching users in your application, it's important to reset the Pundit user context to ensure that...
[ "README.md" ]
[ { "comment": "```suggestion\r\n def switch_user_to(user)\r\n terminate_session if authenticated?\r\n start_new_session_for user\r\n pundit_reset! # Ensure that the Pundit context is reset for the new user\r\n end\r\n```", "path": "README.md", "hunk": "@@ -582,6 +582,25 @@ def pundit_user\n ...
true
varvet/pundit
838
issue_to_patch
Fix: `Pundit.authorize` when passing a custom cache
We accidentally broke this interface when the internal cache interface changed a while back. ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individ...
a885c790a01355cfc5424c1b203970cdf07e4be6
07c0d93c1cad806002eac5a888cb400d270557b6
diff --git a/.rubocop.yml b/.rubocop.yml index 4bc466f9..a86d3184 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -39,6 +39,9 @@ Layout/CaseIndentation: Layout/FirstArrayElementIndentation: EnforcedStyle: consistent +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + Layout/EndAlignment: Enfor...
[ ".rubocop.yml", "CHANGELOG.md", "lib/pundit.rb", "spec/pundit_spec.rb", "spec/support/lib/custom_cache.rb" ]
[]
diff --git a/spec/pundit_spec.rb b/spec/pundit_spec.rb index 65d13b77..260b5a2e 100644 --- a/spec/pundit_spec.rb +++ b/spec/pundit_spec.rb @@ -125,6 +125,18 @@ expect(Pundit.authorize(user, [:project, comment], :create?, policy_class: PublicationPolicy)).to be_truthy end end + + context "when pa...
true
varvet/pundit
836
issue_to_patch
Make error message from `permit` more useful when you forget `permissions`
This tripped me up a bit the other day, so lets improve it. ## To do - [x] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute). - [x] I have added relevant tests. - [x] I have adjusted relevant documentation. - [x] I have made sure the individual commits are meaningful. - [x...
d0d9f2ba9fa3d4f6b5d8bdf99820f37f1df0c43b
d1c3d90a32cc95115339a3942816107acf6d088c
diff --git a/CHANGELOG.md b/CHANGELOG.md index 31eac5fc..674c0417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Deprecated `Pundit::SUFFIX`, moved it to `Pundit::PolicyFinder::SUFFIX` (#835) - Explicitly require less of `active_support` (#837) +- Using `permit` matcher without a surrouding `permiss...
[ "CHANGELOG.md", "lib/pundit/rspec.rb", "spec/rspec_dsl_spec.rb" ]
[]
diff --git a/spec/rspec_dsl_spec.rb b/spec/rspec_dsl_spec.rb index c1f65dae..45fd6307 100644 --- a/spec/rspec_dsl_spec.rb +++ b/spec/rspec_dsl_spec.rb @@ -36,6 +36,16 @@ end describe "#permit" do + context "when not appropriately wrapped in permissions" do + it "raises a descriptive error" do + e...
true