Skip to content

[BUG]: Hard-coded extension assumption breaks filename generation #247

@ishansurdi

Description

@ishansurdi

name: 🐛 Bug Report
about: Create a report to help us improve FireForm.
title: "[BUG]: Hard-coded extension assumption breaks filename generation"
labels: bug
assignees: ''


⚡️ Describe the Bug

There's a problem in src/filler.py at line 17 where it does pdf_form[:-4] to cut off the file extension. Thing is, this only works if your file ends with .pdf (4 characters). If you try using backup files or files that don't have extensions, it just cuts off the last 4 characters no matter what, which messes up the filename pretty bad.

👣 Steps to Reproduce

Just run it with filenames like these:

  • document.pdf.backup - output becomes document.pdf.ba_...filled.pdf (loses the "ckup" part)
  • contract_2024 - output becomes contract__...filled.pdf (the 2024 disappears)

If you process multiple contracts like contract_2024, contract_2025, etc they all end up with the same name and start overwriting each other.

📉 Expected Behavior

It should work with any kind of filename, not just .pdf files.

🖥️ Environment Information

  • OS: Windows 11
  • Docker/Compose Version: N/A
  • Ollama Model used: N/A

📸 Screenshots/Logs

# what the code does now (line 17):
output_pdf = pdf_form[:-4] + "_" + timestamp + "_filled.pdf"

# breaks when you use:
"file.pdf.backup""file.pdf.ba_..."  
"contract_2024""contract__..."    

🕵️ Possible Fix

Could use pathlib to do this properly:

from pathlib import Path
base_name = Path(pdf_form).stem
output_pdf = f"{base_name}_{timestamp}_filled.pdf"

btw I noticed this same issue was in Issue #9 Bug #7 for backend.py but when they refactored it into filler.py the bug got copied over and Issue #9 got closed without actually fixing this part.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions