-
Notifications
You must be signed in to change notification settings - Fork 1
Nomalized Name Collisons #142
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
base: main
Are you sure you want to change the base?
Conversation
…e sames for stronger string safety
…ed user supplied names to prevent collisions due to normalization
…normalized names to prevent collisions
…as a normalization collision
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses normalized name collisions by implementing a robust collision handling system for resource logical IDs. The solution improves upon the previous normalization approach by creating unique kebab-case identifiers with numeric suffixes when conflicts arise.
- Introduces a collision-aware ID generation function that appends suffixes to prevent conflicts
- Enhances the normalization function to create kebab-case names with better readability
- Updates AWS stack generation to use the new collision-safe ID system
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
api/src/app/utils/name_utils.py |
Enhanced normalization function to create kebab-case names and validate non-empty results |
api/src/app/utils/cdktf_utils.py |
Added gen_resource_logical_ids function for collision-safe ID generation with deterministic suffix assignment |
api/src/app/core/cdktf/stacks/aws_stack.py |
Updated to use new collision-safe logical ID generation for VPCs and subnets |
api/src/app/core/cdktf/ranges/base_range.py |
Modified Terraform output parsing to use new logical ID system |
api/tests/unit/utils/test_name_utils.py |
Comprehensive test suite for the enhanced normalization function |
api/tests/unit/utils/test_cdktf_utils.py |
Test coverage for collision handling and logical ID generation |
api/tests/common/api/v1/config.py |
Added test case for normalized name collision scenario |
Comments suppressed due to low confidence (2)
api/tests/unit/utils/test_name_utils.py:78
- The test only checks for the word 'empty' in the error message, but the actual error message contains 'Name is empty after normalization'. Consider using a more specific match pattern like 'Name is empty after normalization' to ensure the correct error is being raised.
with pytest.raises(ValueError, match="empty"):
api/tests/unit/utils/test_cdktf_utils.py:85
- Similar to the name_utils test, consider using a more specific match pattern like 'Input list contains duplicate names' to ensure the correct error message is being tested.
with pytest.raises(ValueError, match="duplicate"):
Checklist
Description
This PR builds on the solution in PR #139 by creating a function that generates unique logical ids for resources by normalizing them (like before) and then appending suffixes to prevent name collisions. For example, the names
My Subnetandmy subnet-->my-subnetandmy-subnet-1which would collide before.Additionally, this PR improves the normalization function to create kebab case names for better readability and cross cloud compatibility.
Fixes known issue 1 in: #139