Skip to content
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

fix(core): the string 'undefined' is recognized as a valid partition when looking up for fact values #23023

Merged
merged 3 commits into from
Nov 22, 2022

Conversation

huyphan
Copy link
Contributor

@huyphan huyphan commented Nov 21, 2022

When the partition value is the literal string 'undefined' (because it was stringified from the context), it should be treated as if it is actually undefined. When looking up a fact value, the two values are already considered the same in one code path, but are then treated differently in the immediate logic. This is causing a new integration test to fail.

This commit makes the logic consistent.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…value

When the partition value is the literal string 'undefined' (because it
was stringified from the context), it should be treated as if it is
actually undefined. When looking up a fact value, the two values are already
considered the same in one code path, but are then treated differently
in the immediate logic. This is causing a new integration test to fail.

This commit makes the logic consistent.
@gitpod-io
Copy link

gitpod-io bot commented Nov 21, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team November 21, 2022 22:51
@github-actions github-actions bot added repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK p2 labels Nov 21, 2022
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@huyphan
Copy link
Contributor Author

huyphan commented Nov 22, 2022

The pull request linter fails with the following errors:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

I'm not adding extra integration tests because the existing tests are actually failing without this fix, we just don't see the failures because we are not running the tests with --force option. Here's a failure example when that flag is enabled:

# Run this in packages/@aws-cdk/aws-lambda 

❯ yarn integ integ.lambda-insights-mapping.js --update-on-failed --verbose --force
yarn run v1.22.4
$ integ-runner integ.lambda-insights-mapping.js --update-on-failed --verbose --force

Verifying integration test snapshots...

  UNCHANGED  integ.lambda-insights-mapping 3.566s

Snapshot Results:

Tests:    1 passed, 1 total

Running integration tests for failed tests...

Running in parallel across regions: us-east-1, us-east-2, us-west-2
Running test /Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/test/integ.lambda-insights-mapping.js in us-east-1

/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/core/lib/private/region-lookup.js:17
            throw new Error(`region-info: don't have any information for ${factName}. Use 'Fact.register' to provide values, or add partitions to the '${cxapi.TARGET_PARTITIONS}' context value.`);
            ^

Error: region-info: don't have any information for cloudwatch-lambda-insights-version:1_0_54_0_x86_64. Use 'Fact.register' to provide values, or add partitions to the '@aws-cdk/core:target-partitions' context value.
    at Object.deployTimeLookup (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/core/lib/private/region-lookup.js:17:19)
    at Stack.regionalFact (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/core/lib/stack.js:729:32)
    at getVersionArn (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/lib/lambda-insights.js:113:23)
    at InsightsVersion._bind (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/lib/lambda-insights.js:56:26)
    at Function.configureLambdaInsights (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/lib/function.js:662:121)
    at new Function (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/lib/function.js:277:14)
    at Object.<anonymous> (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/test/integ.lambda-insights-mapping.js:7:1)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)

Subprocess exited with error 1
  FAILED     integ.lambda-insights-mapping-integ.lambda-insights-mapping (undefined/us-east-1) 82.296s
      Integration test failed: Error: Command exited with status 1

Test Results:

Tests:    1 failed, 1 total
   --- Integration test metrics ---
Profile undefined + Region us-east-1 total time: 82.297
  /Users/hphan/workspace/aws-cdk/packages/@aws-cdk/aws-lambda/test/integ.lambda-insights-mapping.js: 82.297
Error: Some integration tests failed!
    at main (/Users/hphan/workspace/aws-cdk/packages/@aws-cdk/integ-runner/lib/cli.js:144:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@corymhall corymhall added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Nov 22, 2022
corymhall
corymhall previously approved these changes Nov 22, 2022
Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird one, thanks for the fix!

@aws-cdk-automation aws-cdk-automation dismissed their stale review November 22, 2022 12:35

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

@mergify
Copy link
Contributor

mergify bot commented Nov 22, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot dismissed corymhall’s stale review November 22, 2022 12:59

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Nov 22, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: eff1f14
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 6f4dcfd into aws:main Nov 22, 2022
@mergify
Copy link
Contributor

mergify bot commented Nov 22, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants