Open
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
Contributor
There was a problem hiding this comment.
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"):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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