Skip to content

fix: await hasConfigurationChanged before deciding to update the configuration - #77

Open
sarankumar1325 wants to merge 1 commit into
aws-actions:mainfrom
sarankumar1325:fix/await-has-configuration-changed
Open

sarankumar1325 wants to merge 1 commit into
aws-actions:mainfrom
sarankumar1325:fix/await-has-configuration-changed

Conversation

@sarankumar1325

Copy link
Copy Markdown

Issue #, if available: Fixes #76

Description of changes:

hasConfigurationChanged() is async, but run() called it without await. configChanged was therefore always a pending Promise, which is truthy, so:

  • UpdateFunctionConfiguration and the update waiter ran on every deploy, even when the configuration already matched the inputs. The README says it is skipped in that case.
  • With dry-run: true, the action always stopped at [DRY RUN] Configuration updates are not simulated in dry run mode and returned before the DryRun code update, so the code was never validated.

Changes:

  • index.js: const configChanged = await hasConfigurationChanged(...).

  • dist/index.js: rebuilt with npm run build. The only change is the same one-line await.

  • New __tests__/run_config_change_detection.test.js. It drives run() with the real hasConfigurationChanged(); the existing run() tests mock it with a plain boolean, which is why they missed this bug. The tests check that:

    • an unchanged config logs No configuration changes detected and skips UpdateFunctionConfigurationCommand.
    • a changed input (memory size) still sends UpdateFunctionConfigurationCommand.
    • a dry run with an unchanged config reaches UpdateFunctionCodeCommand with DryRun: true.

    On main, the first and third tests fail and the second passes.

Testing: npx jest passes (17 suites, 246 tests). npm run lint gives 0 errors; the 2 warnings it prints are already on main in container_image_support.test.js.

The false-positive comparisons from #50 / #62 are a separate problem and are not changed here.

I used an AI assistant to write this change. I reviewed it and ran the tests above myself.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…iguration

hasConfigurationChanged() is async, but run() called it without await.
The pending Promise is always truthy, so UpdateFunctionConfiguration ran
on every deploy, and with dry-run enabled the action returned at
"Configuration updates are not simulated" without ever doing the
DryRun code update.

Await the result and rebuild dist/. Add tests that go through run() with
the real comparison: unchanged config skips the update, a changed input
still updates, and dry run reaches the DryRun code update.

Fixes aws-actions#76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hasConfigurationChanged() is not awaited, so UpdateFunctionConfiguration runs on every deploy (and dry-run skips code validation)

1 participant