Skip to content

[Pipeline B] Fix positional PDF field-matching in Filler (#642) - #656

Merged
marcvergees merged 1 commit into
fireform-core:development-approach-bfrom
abhishek-8081:issue-642-filler-name-matching
Aug 9, 2026
Merged

[Pipeline B] Fix positional PDF field-matching in Filler (#642)#656
marcvergees merged 1 commit into
fireform-core:development-approach-bfrom
abhishek-8081:issue-642-filler-name-matching

Conversation

@abhishek-8081

Copy link
Copy Markdown
Collaborator

Closes #642.

Filler.fill_form matched extracted values to PDF widgets by positional index (values in
field-dict order zipped to widgets sorted by physical position). This worked only because
the field-dict order coincidentally matched the widget order — if they ever diverged, values
landed in the wrong boxes on emergency reports.

Now matches by field NAME: for each widget, its name (_pdf_text(annot.T)) is looked up in
the extracted answers. The widget name, the template field name, and the answer-dict key are
the same string (prepare_fillable names widgets after fields; the LLM keys answers by field
name), so name-matching is exact. Unmatched widgets are left unfilled; unmatched answers
aren't drawn. The positional sort is removed — order no longer affects correctness.

New tests (tests/test_filler.py): the key one places widgets in a different physical order
than the field-dict order and asserts each value lands in its correctly-named box — this
fails under the old positional code and passes now. Plus unmatched-widget and
unmatched-answer robustness tests.

155 tests pass (152 + 3 new). ruff clean.

Note: _pdf_text is duplicated into filler.py (with a sync comment) to avoid a circular
import (template → controller → file_manipulator → filler → template) — same pattern as
_resolve_project_file. Worth folding into the path/helper consolidation follow-up.

@marcvergees
marcvergees merged commit 2923f11 into fireform-core:development-approach-b Aug 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants