Skip to content

fix: missing Union import, hardcoded extension, multi-page index reset, Ollama timeout#307

Open
vidhip222 wants to merge 2 commits intofireform-core:mainfrom
vidhip222:fix/ollama-timeout-extension-union
Open

fix: missing Union import, hardcoded extension, multi-page index reset, Ollama timeout#307
vidhip222 wants to merge 2 commits intofireform-core:mainfrom
vidhip222:fix/ollama-timeout-extension-union

Conversation

@vidhip222
Copy link

@vidhip222 vidhip222 commented Mar 21, 2026

Description:

Four bug fixes across the PDF filling pipeline and LLM integration layer.

  1. src/main.py: Add missing Union import (Fixes [BUG]: Make exec fails because Union is not imported in src/main.py #274)
    run_pdf_fill_process used Union[str, os.PathLike] in its type annotation but Union was never imported, causing a NameError on any call to this function.

  2. src/filler.py: Replace hardcoded extension slicing (Fixes [BUG]: Hard-coded extension assumption breaks filename generation #247)
    pdf_form[:-4] silently assumed a 4-character .pdf extension, producing corrupted output filenames for any other extension. Replaced with os.path.splitext() which correctly handles any file extension.

  3. src/filler.py: Fix multi-page PDF field index reset (Fixes [BUG]: Multi-page PDF filling resets answer index and misaligns fields #238)
    The answer index i was initialised inside the page loop, resetting to 0 on every page. Fields on pages 2+ were incorrectly filled with values already used on page 1. Moved i outside the loop so it advances continuously across all pages.

  4. src/llm.py: Add timeout to Ollama requests (Fixes [BUG]: Ollama request path lacks timeout and robust error handling #228)
    requests.post() had no timeout, causing the server to hang indefinitely if Ollama was slow or unresponsive. Added a 60-second timeout and a dedicated Timeout exception handler with a descriptive error message.

Issues:

Fixes #274
Fixes #247
Fixes #238
Fixes #228

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Verified os.path.splitext() produces correct filenames for .pdf inputs
  • Verified answer index advances correctly across multi-page PDFs
  • Verified Union import resolves the NameError in run_pdf_fill_process
  • Verified timeout=60 and Timeout handler surface a clear error instead of hanging

Test Configuration:

  • Python: 3.x
  • OS: Windows 11

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant