From 00edd86c1cc9235207474113cd72a0dcd9e775eb Mon Sep 17 00:00:00 2001 From: Rustem Kamalov Date: Sat, 18 Jul 2026 21:31:46 +0300 Subject: [PATCH] fix: openapi yaml parse error + /extract/batch timeout exemption --- core/middleware.go | 4 ++-- core/server_timeout_test.go | 7 +++++-- docs/openapi.yaml | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/middleware.go b/core/middleware.go index dd407c2..0019ef1 100644 --- a/core/middleware.go +++ b/core/middleware.go @@ -65,10 +65,10 @@ func RequestContextMiddleware() fiber.Handler { // RequestTimeoutMiddleware bounds wall-clock time per request by attaching a // deadline to the user context, which fasthttp never cancels on client -// disconnect. /mega/* (MegaTimeout) and /extract (batch budget) are exempt. +// disconnect. /mega/* (MegaTimeout) and /extract* (batch budget) are exempt. func RequestTimeoutMiddleware(timeout time.Duration) fiber.Handler { return func(c *fiber.Ctx) error { - if strings.HasPrefix(c.Path(), "/mega/") || c.Path() == "/extract" { + if strings.HasPrefix(c.Path(), "/mega/") || c.Path() == "/extract" || c.Path() == "/extract/batch" { return c.Next() } ctx, cancel := context.WithTimeout(c.UserContext(), timeout) diff --git a/core/server_timeout_test.go b/core/server_timeout_test.go index 709103c..a815768 100644 --- a/core/server_timeout_test.go +++ b/core/server_timeout_test.go @@ -12,8 +12,8 @@ import ( ) // FP-2: every endpoint that doesn't manage its own deadline budget must get -// one from RequestTimeoutMiddleware; /mega/* (MegaTimeout) and /extract -// (batch budget) keep theirs. +// one from RequestTimeoutMiddleware; /mega/* (MegaTimeout) and /extract, +// /extract/batch (batch budget) keep theirs. func TestRequestTimeoutMiddlewareSetsDeadlineExceptBudgetedPaths(t *testing.T) { app := fiber.New() app.Use(RequestTimeoutMiddleware(time.Minute)) @@ -32,12 +32,14 @@ func TestRequestTimeoutMiddlewareSetsDeadlineExceptBudgetedPaths(t *testing.T) { app.Post("/google/parse", record("/google/parse")) app.Get("/mega/search", record("/mega/search")) app.Get("/extract", record("/extract")) + app.Post("/extract/batch", record("/extract/batch")) for path, method := range map[string]string{ "/google/search": http.MethodGet, "/google/parse": http.MethodPost, "/mega/search": http.MethodGet, "/extract": http.MethodGet, + "/extract/batch": http.MethodPost, } { req := httptest.NewRequest(method, path, nil) resp, err := app.Test(req, -1) @@ -54,6 +56,7 @@ func TestRequestTimeoutMiddlewareSetsDeadlineExceptBudgetedPaths(t *testing.T) { "/google/parse": true, "/mega/search": false, "/extract": false, + "/extract/batch": false, } { if deadlines[path] != want { t.Errorf("%s: deadline attached = %v, want %v", path, deadlines[path], want) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index 4998eec..9e57353 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -2080,7 +2080,7 @@ components: mode: type: string enum: [auto, fast, rendered] - description: Extraction mode (default: auto) + description: "Extraction mode (default: auto)" BatchExtractItem: type: object