Skip to content

[BUG]: 'Union' not defined in main.py #135

Closed

Description

@Cubix33

⚡️ Describe the Bug

Running the application via the make exec command crashes immediately upon startup with a NameError: name 'Union' is not defined. This occurs because Union is used for type hinting the pdf_form_path parameter in the run_pdf_fill_process function signature in src/main.py, but the module is never imported.

👣 Steps to Reproduce

  1. Ensure the Docker containers are running (docker compose up -d).
  2. Run the command make exec (or docker compose exec app python3 src/main.py) in the terminal.
  3. See the NameError crash output immediately.

📉 Expected Behavior

The application should start successfully, detect the PDF, and begin the extraction/filling process without throwing Python standard library import errors.

🖥️ Environment Information

  • OS: Windows / WSL 2 (Ubuntu)
  • Docker/Compose Version: Docker Desktop latest
  • Ollama Model used: Mistral

📸 Screenshots/Logs

Traceback (most recent call last):
  File "/app/src/main.py", line 14, in <module>
    def run_pdf_fill_process(user_input: str, definitions: list, pdf_form_path: Union[str, os.PathLike]):
                                                                                ^^^^^
NameError: name 'Union' is not defined

🕵️ Possible Fix

Add the missing import statement from the standard typing library at the top of src/main.py:

from typing import Union

Activity

  1. Dotify71 commented on May 15, 2026

    @Dotify71

    Hi! I've submitted PR #407 which fixes this NameError by adding the missing Union import. The PR also includes a new feature for mapping PDF checkboxes and radio buttons. Ready for review!

  2. marcvergees commented on May 15, 2026

    @marcvergees
    Member

    In the current /main branch there's no use of Union, in fact is a bad practice. Starting with Python 3.10 (PEP 604), you should use the pipe operator (|) instead of typing.Union for type hints.
    Old way: typing.Union[int, str]
    New way: int | str

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

Metadata

Metadata

Assignees

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