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

Missing configuration options result in unclear, uncaught error messages #279

Open
C0rn3j opened this issue Nov 4, 2024 · 1 comment
Open

Comments

@C0rn3j
Copy link

C0rn3j commented Nov 4, 2024

It would be nice if these config issues were caught with a human readable error thrown back, the current error with this wrong config made me think downstream pkgctl wasn't using the config correctly.

# Wrong config I tried to use that throws the problematic error message
# git = is not needed to repro
[vtracer]
source = "github"
git = "https://github.com/visioncortex/vtracer.git"

# Working config, just to be clear
[vtracer]
source = "github"
github = "visioncortex/vtracer"
use_latest_release = true
% nvchecker -c nvchecker.toml
[E 11-04 20:37:09.918 core:369] vtracer: unexpected error happened error=KeyError('github')
    Traceback (most recent call last):
      File "/usr/lib/python3.12/site-packages/nvchecker/util.py", line 311, in run_one
        version = await self.func(
                  ^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.12/site-packages/nvchecker_source/github.py", line 39, in get_version
        return await get_version_real(name, conf, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.12/site-packages/nvchecker_source/github.py", line 158, in get_version_real
        repo = conf['github']
               ~~~~^^^^^^^^^^
    KeyError: 'github'
[E 11-04 20:37:09.919 core:447] vtracer: no-result error="'github'"

repo = conf['github']

@lilydjwg
Copy link
Owner

lilydjwg commented Nov 5, 2024

Yes, the latter error message is quite confusing. I'm changing str(e) to repr(e) as some builtin Python exceptions has such messages.

A better way to handle this is to validate the config file via a schema, but that's a lot of work to do...

lilydjwg added a commit that referenced this issue Nov 5, 2024
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

No branches or pull requests

2 participants