Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opaque traceback on malformed pyproject.toml #135

Open
lordmauve opened this issue Jan 28, 2025 · 0 comments · May be fixed by #140
Open

Opaque traceback on malformed pyproject.toml #135

lordmauve opened this issue Jan 28, 2025 · 0 comments · May be fixed by #140

Comments

@lordmauve
Copy link
Contributor

A user experienced a crash due to a malformed pyproject.toml:

Traceback (most recent call last):
  File "/home/user/project/.venv/bin/thx", line 5, in <module>
    from thx.main import main
  File "/home/user/project/.venv/lib/python3.12/site-packages/thx/main.py", line 63, in <module>
    @click.group(cls=ThxGroup, chain=True, invoke_without_command=True, help=__doc__)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/click/decorators.py", line 238, in decorator
    cmd = cls(
          ^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/thx/main.py", line 39, in __init__
    self.config = load_config()
                  ^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/thx/config.py", line 135, in load_config
    data = tomli.loads(content).get("tool", {}).get("thx", {})
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/tomli/_parser.py", line 107, in loads
    pos = key_value_rule(src, pos, out, header, parse_float)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/tomli/_parser.py", line 331, in key_value_rule
    pos, key, value = parse_key_value_pair(src, pos, parse_float)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/tomli/_parser.py", line 374, in parse_key_value_pair
    pos, value = parse_value(src, pos, parse_float)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/tomli/_parser.py", line 621, in parse_value
    return parse_array(src, pos, parse_float)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/tomli/_parser.py", line 425, in parse_array
    pos, val = parse_value(src, pos, parse_float)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/project/.venv/lib/python3.12/site-packages/tomli/_parser.py", line 654, in parse_value
    raise suffixed_err(src, pos, "Invalid value")
tomli.TOMLDecodeError: Invalid value (at line 13, column 5)

The user was not familiar with TOML and made a mistake in editing it. But this error did not guide them towards the root cause and they were unable to self-resolve it.

amyreese added a commit to amyreese/thx that referenced this issue Feb 3, 2025
@amyreese amyreese linked a pull request Feb 3, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant