[Pipeline B] Fix positional PDF field-matching in Filler (#642) - #656
Merged
marcvergees merged 1 commit intoAug 9, 2026
Conversation
marcvergees
merged commit Aug 9, 2026
2923f11
into
fireform-core:development-approach-b
2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.