Conversation
… test reliability - 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
seshubaws
approved these changes
Feb 13, 2026
vicheey
approved these changes
Feb 13, 2026
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.
Problem
Four sync integration tests were failing:
TestSyncWatchInfraWithInvalidTemplate::test_sync_watch_infra- ValueError: The watch process crashed when an invalid template was applied duringsam sync --watch.TestSyncAdlWithWatchStartWithNoDependencies::test_sync_watch_code- TimeoutError (60s): Layer sync operations exceeded the 60s timeout.TestSyncInfraNestedStacks_0::test_sync_watch_infra_nested_stack- TimeoutError (600s): Nested stack infra sync exceeded the 600s timeout.TestSyncInfraNestedStacks_1::test_sync_watch_infra_nested_stack- TimeoutError (600s): Same as above.Root Cause
The
ValueErrorwas caused by an unhandled exception inwatch_manager.py. When infra sync fails (e.g., invalid template), the error handler calls_add_template_triggers()to re-register file watchers. However,_add_template_triggers()callsSamLocalStackProvider.get_stacks()which can also throw if the template is unparseable. This unhandled exception propagated up and crashed the watch process's main loop, causing the process to exit.The
TimeoutErrorfailures were due to timeouts that were too tight for the operations being performed.Fix
samcli/lib/sync/watch_manager.py: Wrap_add_template_triggers()in try/except within the infra sync error handler so the watch process survives and can recover when the template is fixed.tests/testing_utils.py: Add descriptive message to the bareraise ValueError()inread_until, and catchValueErrorinread_until_stringto include expected output context for better debugging.tests/integration/sync/test_sync_adl.py: Increase layer sync timeouts from 60s to 120s.tests/integration/sync/test_sync_watch.py: Increase nested stack infra sync timeout from 600s to 900s.Testing
Verified with real AWS deployments on fork — all 4 tests passed in two consecutive runs: