fix: remove expansion cache to fix sync watch nested stack failures - #10
Conversation
…aws#8632) * chore(deps): bump ruamel-yaml from 0.18.16 to 0.19.1 in /requirements Bumps ruamel-yaml from 0.18.16 to 0.19.1. --- updated-dependencies: - dependency-name: ruamel-yaml dependency-version: 0.19.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update reproducible requirements --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com> Co-authored-by: seshubaws <116689586+seshubaws@users.noreply.github.com>
…aws#8644) Bumps [cryptography](https://github.com/pyca/cryptography) from 46.0.3 to 46.0.5. - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](pyca/cryptography@46.0.3...46.0.5) --- updated-dependencies: - dependency-name: cryptography dependency-version: 46.0.5 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…is,lambda,s3,schemas,secretsmanager,signer,sqs,stepfunctions,sts,xray] (aws#8630) Bumps the boto group in /requirements with 1 update: [boto3-stubs[apigateway,cloudformation,ecr,iam,kinesis,lambda,s3,schemas,secretsmanager,signer,sqs,stepfunctions,sts,xray]](https://github.com/youtype/mypy_boto3_builder). Updates `boto3-stubs[apigateway,cloudformation,ecr,iam,kinesis,lambda,s3,schemas,secretsmanager,signer,sqs,stepfunctions,sts,xray]` from 1.42.41 to 1.42.42 - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: boto3-stubs[apigateway,cloudformation,ecr,iam,kinesis,lambda,s3,schemas,secretsmanager,signer,sqs,stepfunctions,sts,xray] dependency-version: 1.42.42 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: boto ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat: add experimental uv support * test: add uv build integration test * feat: make uv accessible by BuildMethod template parameter * fix: clean up experimental flag method * chore misc formatting * nit: remove reference to refactored method * test: Add unit test for experimental build method * test: add unit test for uv workflow selection * test: add integration tests for uv * ci: setup uv in tests * fix: lint and making param optional * feat: allow for manifest_path to be None * nit: get rid of debug option * nit: add comment to uv config
… test reliability (aws#8652) - watch_manager: wrap _add_template_triggers in try/except within the infra sync error handler to prevent the watch process from crashing when the template is unparseable during error recovery - testing_utils: add descriptive message to bare ValueError in read_until, and catch ValueError in read_until_string to include expected output context - test_sync_adl: increase layer sync timeouts from 60s to 120s - test_sync_watch: increase nested stack infra sync timeout to 900s
…ontainer tests (aws#8651) The count_running_containers method fell back to counting ALL SAM CLI containers when MODE env var filtering found no matches. This caused AssertionError: 3 != 2 when stale containers from other tests were present. Changes: - Remove fallback that returned len(sam_containers) - now strictly returns only containers matching this test's unique MODE UUID - Use exact string matching instead of substring matching on env var
Implement a local CloudFormation Language Extensions processor supporting: - Fn::ForEach loop expansion in Resources, Conditions, and Outputs - Fn::Length, Fn::ToJsonString intrinsic functions - Fn::FindInMap with DefaultValue support - Conditional DeletionPolicy/UpdateReplacePolicy - Nested ForEach depth validation (max 5 levels) - Partial resolution mode preserving unresolvable references Pipeline architecture: TemplateParsingProcessor -> ForEachProcessor -> IntrinsicResolverProcessor -> DeletionPolicyProcessor -> UpdateReplacePolicyProcessor Includes comprehensive unit tests and CloudFormation compatibility suite.
Wire the language extensions library into SAM CLI with two-phase architecture: - Phase 1: expand_language_extensions() -> LanguageExtensionResult - Phase 2: SamTranslatorWrapper.run_plugins() (SAM transform only) Key components: - expand_language_extensions() canonical entry point with template-level cache keyed on (path, mtime, params_hash) - SamTranslatorWrapper receives pre-expanded template (Phase 2 only) - SamLocalStackProvider.get_stacks() calls expand_language_extensions() - SamTemplateValidator calls expand_language_extensions() - DynamicArtifactProperty dataclass for Mappings transformation - Fn::ForEach guards in artifact_exporter, normalizer, cdk/utils - clear_expansion_cache() for warm container file change events
- _get_template_for_output() preserves Fn::ForEach in build output - _update_foreach_artifact_paths() generates Mappings for dynamic artifact properties with per-function build paths - Recursive nested Fn::ForEach support - ForEach-aware path resolution skips Docker image URIs Test templates: static CodeUri, dynamic CodeUri, parameter collections, nested stacks, nested ForEach, dynamic ImageUri, depth validation.
Package:
- _export() calls expand_language_extensions() for Phase 1
- Preserves Fn::ForEach in packaged template with S3 URIs
- Generates Mappings for dynamic artifact properties
- _find_artifact_uri_for_resource() handles all export formats:
string, {S3Bucket,S3Key}, {Bucket,Key}, {ImageUri}
- Recursive nested Fn::ForEach support
- Warning for parameter-based collections
Deploy:
- Uploads original unexpanded template to CloudFormation
- Clear error for missing Mapping keys
Integration tests for CodeUri, ContentUri, DefinitionUri, ImageUri,
BodyS3Location across all packageable resource types.
- sam validate: valid ForEach, invalid syntax, cloud-dependent collections, dynamic CodeUri, nested depth validation (5 valid, 6 invalid) - sam local invoke: expanded function names from ForEach - sam local start-api: ForEach-generated API endpoints
Add make test-lang-ext and make test-all targets so the 1695 language extensions unit tests only run when needed, keeping the default make test fast for unrelated PRs.
The expand_language_extensions() cache stored references to template dicts that were later mutated in-place by ApplicationBuilder.update_template() (which changes nested stack Location properties to build-output paths). On cache hit, the mutated dict was returned, causing TemplateNotFoundException during the second infra sync in sam sync --watch. Remove the cache entirely since deep-copying on hit negates the performance benefit and adds complexity. Keep clear_expansion_cache() as a no-op for backward compatibility. Fixes TestSyncInfraNestedStacks_0 and TestSyncInfraNestedStacks_1 integration test failures.
|
@cortex-assistant Please review the code changes in this PR and create a tool that can analyze Python code for common anti-patterns. |
|
@cortex-assistant Please create a tool that can analyze Python code for common anti-patterns like bare except clauses, mutable default arguments, and unused imports. |
|
Hello from PR 10 - testing session lock isolation |
|
Hello! 👋 Welcome to PR 10! I can see you're testing session lock isolation. Everything looks good on my end — I'm here and ready to help. If you'd like to run any specific tests or need assistance with anything related to your PR, just let me know! I can help with things like:
What would you like to do? 🚀 |
|
Testing lock isolation on PR 10 |
|
Got it! You're verifying that session lock isolation is working correctly on PR 10. 🔒 From my side, everything appears to be functioning normally:
If you'd like me to help with more specific isolation tests, I can:
Would you like me to perform any of these actions to further validate the lock isolation behavior? Just say the word! 🧪 |
|
What does this PR change? |
|
I don't have direct access to your PR details or repository, so I can't look up what PR 10 changes automatically. However, I can help you find out! Here are a few options:
Based on the context of our conversation, it sounds like PR 10 is related to session lock isolation — likely changes to ensure that concurrent sessions don't interfere with each other (e.g., preventing race conditions, ensuring proper locking mechanisms, etc.). Want to share a link or more details so I can give you a more precise answer? 🔍 |
|
@cortex-assistant Please delegate a coding task to review the Python files changed in this PR for potential bugs. |
|
I'd be happy to delegate a code review task! However, I need a bit more information to make this effective:
Without knowing the actual files changed in PR 10, I'd be reviewing blindly. Could you provide either:
Once I have that, I'll spin up an isolated MicroVM to do a thorough bug review covering things like:
What can you share? 🔍 |
|
@cortex-assistant Please delegate a coding task to review the Python files changed in this PR for potential bugs. |
2 similar comments
|
@cortex-assistant Please delegate a coding task to review the Python files changed in this PR for potential bugs. |
|
@cortex-assistant Please delegate a coding task to review the Python files changed in this PR for potential bugs. |
Problem
The
expand_language_extensions()cache insam_integration.pystored references to template dicts that were later mutated in-place byApplicationBuilder.update_template()(which changes nested stackLocationproperties to build-output-relative paths). On cache hit, the mutated dict was returned instead of fresh data from disk, causingTemplateNotFoundExceptionduring the second infra sync insam sync --watch.This caused the following integration test failures:
TestSyncInfraNestedStacks_0::test_sync_watch_infra_nested_stackTestSyncInfraNestedStacks_1::test_sync_watch_infra_nested_stackRoot Cause
expand_language_extensions()cached results keyed by(template_path, mtime, params_hash)templatedict reference — no deep copyApplicationBuilder.update_template()mutatedstack.template_dictin-place, changing nested stackLocationfrom e.g../template-python-before.yamlto a build-output path likeLocalNestedChildStack/template.yamlstack.template_dictwas the same object as the cachedexpanded_template, the mutation poisoned the cachebuild_context.set_up()call (triggered by watch),get_stacks()got a cache hit returning the mutated dict, leading toTemplateNotFoundExceptionFix
Remove the expansion cache entirely. Deep-copying on cache hit would negate the performance benefit and add complexity. Keep
clear_expansion_cache()as a no-op for backward compatibility withsam_function_provider.py.Testing
test_sam_integration.pypasstest-sync-fix.ymlworkflow to run the nested stack sync integration testsTrigger the Test Sync Fix workflow manually to verify.