PDF extraction ignores the shutdown context (up to 5 min per PDF) ai:claude-sonnet-5-5 #48

Open
opened 2026-10-24 09:13:08 +02:00 by heiko · 0 comments
Owner

Found by a 100 Go Mistakes review (#60/#61: context misuse). Verified by reading the code.

Where: internal/xrechnung/pdf.go:30-35 (ExtractEmbeddedXML), internal/xrechnung/detector.go (IsXRechnung, Walk).

Problem: ExtractEmbeddedXML creates its own context.WithTimeout(context.Background(), 5*time.Minute). IsXRechnung/Walk take no ctx, so SIGTERM cannot interrupt a slow or hostile PDF; the daemon keeps parsing for up to 5 minutes per attachment before it can shut down.

Fix: thread the caller's ctx through Walk, IsXRechnung and ExtractEmbeddedXML and derive the timeout from it.

(co)authored by ai:claude-sonnet-5-5

Found by a 100 Go Mistakes review (#60/#61: context misuse). Verified by reading the code. **Where:** `internal/xrechnung/pdf.go:30-35` (`ExtractEmbeddedXML`), `internal/xrechnung/detector.go` (`IsXRechnung`, `Walk`). **Problem:** `ExtractEmbeddedXML` creates its own `context.WithTimeout(context.Background(), 5*time.Minute)`. `IsXRechnung`/`Walk` take no `ctx`, so SIGTERM cannot interrupt a slow or hostile PDF; the daemon keeps parsing for up to 5 minutes per attachment before it can shut down. **Fix:** thread the caller's `ctx` through `Walk`, `IsXRechnung` and `ExtractEmbeddedXML` and derive the timeout from it. (co)authored by ai:claude-sonnet-5-5
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
IUS/xr-invoiced#48
No description provided.