Skip to content

CFn: improve error messages #11591

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

Merged
merged 6 commits into from
Jan 5, 2025
Merged

CFn: improve error messages #11591

merged 6 commits into from
Jan 5, 2025

Conversation

simonrw
Copy link
Contributor

@simonrw simonrw commented Sep 26, 2024

Motivation

When using our CloudFormation implementation, we often don't change errors when they are raised. This usually means the user is faced with horrible Python tracebacks that require our input to resolve.

A much better story is to parse and validate the template by converting the template into a meaningful graph of resources, with parameters, conditions and mappings resolved at template parse time, however we are not quite at that stage yet. The CFn implementation in LocalStack currently works, but is not pretty, and would take some effort to re-write at the moment, and at this stage it is not worth it.

The next best thing is to loose focus on parity with AWS and do what we can by improving error messages on obvious conditions. This PR tackles some of these things.

Changes

  • Add clarity when a mapping key cannot be found in a map, for both first and second level attributes
  • Add clarity to parameters without default values when previous values are not set, and other similar situations

TODO

More improvements...

@simonrw simonrw added the semver: patch Non-breaking changes which can be included in patch releases label Sep 26, 2024
@simonrw simonrw self-assigned this Sep 26, 2024
@simonrw simonrw added this to the Playground milestone Sep 26, 2024
@simonrw simonrw force-pushed the cfn/dx/better-error-messages branch from 13f53f1 to bfb4a18 Compare September 26, 2024 22:33
Copy link

github-actions bot commented Sep 26, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 50m 39s ⏱️ - 1m 34s
3 922 tests +2  3 615 ✅ +2  307 💤 ±0  0 ❌ ±0 
3 924 runs  +2  3 615 ✅ +2  309 💤 ±0  0 ❌ ±0 

Results for commit 94d379b. ± Comparison against base commit c3f72f7.

♻️ This comment has been updated with latest results.

@simonrw
Copy link
Contributor Author

simonrw commented Sep 27, 2024

The CI is green apart from one failing test with the arm tests: tests/aws/services/cloudwatch/test_cloudwatch_metrics.py::TestSQSMetrics::test_alarm_number_of_messages_sent. This is unrelated to this fix.

@simonrw simonrw force-pushed the cfn/dx/better-error-messages branch from bfb4a18 to 0cff704 Compare September 27, 2024 13:59
@simonrw simonrw force-pushed the cfn/dx/better-error-messages branch from 0cff704 to 5109aa9 Compare October 1, 2024 14:00
@simonrw simonrw marked this pull request as ready for review October 1, 2024 15:17
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice addition to improve clarity and allow for more insight into root causes. In terms of the tests, I think it might be good to separate these kind of tests a bit more (e.g. a separate class) but that's more of an optional nit and up for discussion at a later point.

@simonrw simonrw merged commit 3af3830 into master Jan 5, 2025
32 checks passed
@simonrw simonrw deleted the cfn/dx/better-error-messages branch January 5, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants