mirror of
https://github.com/napnap75/multiarch-docker-images.git
synced 2026-11-11 00:22:12 +01:00
fix(pipeline): skip rule evaluation when PDF extraction fails (US-13)
An unreadable PDF was still passed to cfg.Evaluate with nil pages, producing a cascade of spurious errors (index out of range on pages[0], missing mandatory fields) in the imported event. Route straight to pending/ with the extraction failure as the single error.
This commit is contained in:
@@ -74,14 +74,19 @@ func processOne(app core.App, cfg *config.Config, s3 *storage.Client, ctx contex
|
||||
// US-13: page-by-page extraction.
|
||||
pages, extractErr := extractPages(data)
|
||||
var errs []string
|
||||
var fields map[string]any
|
||||
rendered := ""
|
||||
if extractErr != nil {
|
||||
// US-13: an unreadable PDF goes straight to pending/ with the
|
||||
// extraction failure as its only error; the rule engine never
|
||||
// runs on a document without pages.
|
||||
errs = append(errs, "unreadable PDF: "+extractErr.Error())
|
||||
pages = nil
|
||||
} else {
|
||||
// US-14 / US-15: classification and verdict.
|
||||
var evalErrs []string
|
||||
fields, rendered, evalErrs = cfg.Evaluate(pages)
|
||||
errs = append(errs, evalErrs...)
|
||||
}
|
||||
|
||||
// US-14 / US-15: classification and verdict.
|
||||
fields, rendered, evalErrs := cfg.Evaluate(pages)
|
||||
errs = append(errs, evalErrs...)
|
||||
valid := len(errs) == 0 && rendered != ""
|
||||
|
||||
// US-16: the record is created before any physical move.
|
||||
|
||||
Reference in New Issue
Block a user