Skip to content

Missing inventory causes full page backtrace #2087

Open

Description

@goetzk

Describe the bug

When an inventory file is not found instead of a message saying "there is no inventory file" a long backtrace is printed.

To Reproduce

(pyinfra) kgoetz@L23001:~$ pyinfra --diff ../medeopolis-inventory-pyinfra/inventory.py --ssh-user=root -y exec -- "grep http2 /etc/nginx/sites-enabled/*"
--> Loading config...
--> Loading inventory...
    Exception raised during inventory search on: ../medeopolis-inventory-pyinfra/inventory: no package specified for '../medeopolis-inventory-pyinfra/inventory' (required for relative module names)
Traceback (most recent call last):
  File "/home/kgoetz/.venvs/pyinfra/lib/python3.13/site-packages/gevent/threadpool.py", line 173, in __run_task
    thread_result.set(func(*args, **kwargs))
                      ~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/encodings/idna.py", line 198, in encode
    raise UnicodeEncodeError("idna", input, offset, offset+1,
                             "label empty")
UnicodeEncodeError: 'idna' codec can't encode character '\x2e' in position 0: label empty
encoding with 'idna' codec failed
2026-11-18T22:00:00Z (<ThreadPoolWorker at 0x7f603e33bdc0 thread_ident=0x7f603df636c0 threadpool-hub=<Hub at 0x7f6041763330 thread_ident=0x7f604179a780>>, <built-in function getaddrinfo>) failed with UnicodeEncodeError

--> An internal exception occurred:
...
UnicodeEncodeError: 'idna' codec can't encode character '\x2e' in position 0: label empty
[NOTE] encoding with 'idna' codec failed
--> The full traceback has been written to pyinfra-debug.log
--> If this is unexpected please consider submitting a bug report on GitHub, for more information run `pyinfra --support`.

Expected behavior

a one or two line message saying the inventory file can't be found.

Meta

installed through pip.

(pyinfra) kgoetz@L23001:~$ pyinfra --support

    If you are having issues with pyinfra or wish to make feature requests, please
    check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
    When adding an issue, be sure to include the following:

    System: Linux
      Platform: Linux-6.12.111+deb13-amd64-x86_64-with-glibc2.41
      Release: 6.12.111+deb13-amd64
      Machine: x86_64
    pyinfra: v3.11.0
      cyclopts: v4.25.3
      distro: v1.9.0
      gevent: v25.9.1
      jinja2: v3.1.6
      packaging: v25.0
      paramiko: v3.5.1
      pydantic: v2.13.4
      python-dateutil: v2.9.0.post0
      rich: v15.0.0
      typeguard: v4.4.4
      types-paramiko: v4.0.0.20260518
      typing-extensions: v4.15.0
    Executable: /home/kgoetz/.venvs/pyinfra/bin/pyinfra
    Python: 3.13.5 (CPython, GCC 14.2.0)

Activity

  1. added
    bug
    operations
    connectors
    on Nov 18, 2026
  2. goetzk commented on Nov 19, 2026

    @goetzk
    ContributorAuthor

    I've started to organise a fix but will need to set up a test environment before i can, with clean conscience, tick all the boxes in the PR form.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconnectorsoperations

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions