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

[Bug]: KeyError: 'default' #43

Open
MHendricks opened this issue May 2, 2023 · 0 comments
Open

[Bug]: KeyError: 'default' #43

MHendricks opened this issue May 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@MHendricks
Copy link
Member

Summary

Provide easier to understand feedback when running into this error. This happens when there is no default config found.

Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python39\lib\site-packages\hab\__main__.py", line 14, in <module>
    sys.exit(hab.cli.cli(prog_name="python -m hab"))
  File "C:\Program Files\Python39\lib\site-packages\hab\cli.py", line 425, in cli
    return _cli(*args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\click\decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\hab\cli.py", line 414, in launch
    settings.write_script(
  File "C:\Program Files\Python39\lib\site-packages\hab\cli.py", line 111, in write_script
    ret = self.resolver.resolve(uri)
  File "C:\Program Files\Python39\lib\site-packages\hab\__init__.py", line 268, in resolve
    context = self.closest_config(uri)
  File "C:\Program Files\Python39\lib\site-packages\hab\__init__.py", line 123, in closest_config
    return self.closest_config(path, default=True)
  File "C:\Program Files\Python39\lib\site-packages\hab\__init__.py", line 103, in closest_config
    current = self.configs["default"]
KeyError: 'default'

Expected Behavior

.

Steps to Reproduce Behavior

Setup a hab environment that doesn't have a default configuration.

Solution

Make this return a descriptive error message indicating that there was no default configuration to use so it couldn't resolve the uri.

Environment

Hab==0.16.0

Additional Context

.

@MHendricks MHendricks added the bug Something isn't working label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant