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

All errors related to a specific stack should include the stack name in the error message. #1306

Open
dboitnot opened this issue Feb 13, 2023 · 1 comment

Comments

@dboitnot
Copy link
Contributor

All errors related to a specific stack should include the stack name in the error message.

Because Sceptre may be evaluating several stack configurations at once, an error may be difficult to troubleshoot if it's coming from a stack other than the one being launched/updated/whatever. This is a generalization of #1267. Rather than adding the stack path to messages as they're raised, recommend trapping stack errors and re-throwing them with the stack path.

This will let us avoid updating all the raise sites as well as improving errors thrown outside Sceptre code.

Expected behaviour

Stack trace should include the path of the failing stack configuration.

Actual behaviour

Traceback (most recent call last):
  File "/usr/local/bin/sceptre", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/sceptre/cli/helpers.py", line 43, in decorated
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/sceptre/cli/delete.py", line 41, in delete_command
    plan = SceptrePlan(context)
  File "/usr/local/lib/python3.9/site-packages/sceptre/plan/plan.py", line 48, in __init__
    all_stacks, command_stacks = self.config_reader.construct_stacks()
  File "/usr/local/lib/python3.9/site-packages/sceptre/config/reader.py", line 252, in construct_stacks
    stack = self._construct_stack(rel_path, stack_group_config)
  File "/usr/local/lib/python3.9/site-packages/sceptre/config/reader.py", line 575, in _construct_stack
    stack = Stack(
  File "/usr/local/lib/python3.9/site-packages/sceptre/stack.py", line 175, in __init__
    raise InvalidConfigFileError(
sceptre.exceptions.InvalidConfigFileError: Neither 'template_path' nor 'template' is set
@jfalkenstein
Copy link
Contributor

I think this error message will be different in v4. template_path is officially deprecated. Nonetheless, I think something along the lines of this might resolve the issue:

try:
    # do the stuff in the Stack __init__()
except Exception as e:
    raise InvalidConfigFileError(f'{name}: {e}) from e

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

No branches or pull requests

2 participants