PDF/XML errors are silently discarded ai:claude-sonnet-5-5 #52

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

Priority: minor

Found by a 100 Go Mistakes review (#53/#54 error handling). Verified by reading the code.

Where: internal/xrechnung/pdf.go:50-57,75-78, internal/xrechnung/detector.go:36-38, internal/scanner/scanner.go:175-186

Problem: extractEmbeddedXML returns nil, nil for any non-context error from ExtractAttachmentsRaw and continues on a failed io.ReadAll; IsXRechnung drops the Detect error (false, nil); fetchBody returns only the close error when both read and close fail. A corrupt/unsupported invoice is indistinguishable from "not an invoice" and nothing is logged.

Fix: Log (debug/warn) or return a distinguishable "unreadable" error; use errors.Join(readErr, closeErr) in fetchBody.

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

**Priority: minor** Found by a 100 Go Mistakes review (#53/#54 error handling). Verified by reading the code. **Where:** `internal/xrechnung/pdf.go:50-57,75-78`, `internal/xrechnung/detector.go:36-38`, `internal/scanner/scanner.go:175-186` **Problem:** `extractEmbeddedXML` returns `nil, nil` for any non-context error from `ExtractAttachmentsRaw` and `continue`s on a failed `io.ReadAll`; `IsXRechnung` drops the `Detect` error (`false, nil`); `fetchBody` returns only the close error when both read and close fail. A corrupt/unsupported invoice is indistinguishable from "not an invoice" and nothing is logged. **Fix:** Log (debug/warn) or return a distinguishable "unreadable" error; use `errors.Join(readErr, closeErr)` in `fetchBody`. (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#52
No description provided.