Skip to content

Adjust error message to show that the capacity reservation does not exist #6887

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

Open
wants to merge 2 commits into
base: release-3.13
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/src/pcluster/models/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@
except ConfigValidationError as e:
raise e
except Exception as e:
if "Invalid type for parameter InstanceTypes[0], value: None, type: <class 'NoneType'>" in e.__str__():
Copy link
Contributor

Choose a reason for hiding this comment

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

The logici around exception raising should not be based on error messages, as it is a fragile approach. Error messages are meant to change over time.
The logic should be based on something more stable, such as exception types.

raise ConfigValidationError(f"Invalid cluster configuration: Capacity reservation does not exist.")

Check warning on line 504 in cli/src/pcluster/models/cluster.py

View check run for this annotation

Codecov / codecov/patch

cli/src/pcluster/models/cluster.py#L503-L504

Added lines #L503 - L504 were not covered by tests
raise ConfigValidationError(f"Invalid cluster configuration: {e}")

return config, validation_failures
Expand Down
Loading