Skip to content

fix: context provider's ignoreErrorOnMissingContext parameter is misleading #33875

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

Merged
merged 8 commits into from
Mar 25, 2025

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 22, 2025

In ContextProvider.getValue(), ignoreErrorOnMissingContext is a request to the CLI's context provider to not fail the lookup, but return the dummy value instead.

The operation doesn't have anything to do with missing context, and missing context isn't an error. Deprecate that parameter and add mustExist instead (with reversed semantics).

Also explain the dummyValue field and this one a bit better.


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

@rix0rrr rix0rrr requested a review from a team as a code owner March 22, 2025 14:48
@github-actions github-actions bot added the p2 label Mar 22, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 22, 2025 14:48
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 22, 2025
@rix0rrr rix0rrr force-pushed the huijbers/explain-contextprovider-dummy-value branch from ead00e7 to ade07ed Compare March 22, 2025 14:49
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.

(This review is outdated)

@rix0rrr rix0rrr force-pushed the huijbers/explain-contextprovider-dummy-value branch from ade07ed to cc112a9 Compare March 22, 2025 14:51
…sleading

In `ContextProvider.getValue()`, `ignoreErrorOnMissingContext` is a
request to the CLI's context provider to not fail the lookup, but return
the dummy value instead.

The operation doesn't have anything to do with missing context, and
missing context isn't an error. Deprecate that parameter and add
`ignoreFailedLookup` instead.

Also explain the `dummyValue` field and this one a bit better.
Copy link

codecov bot commented Mar 22, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.35%. Comparing base (7f2ed96) to head (d46b51d).

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #33875      +/-   ##
==========================================
- Coverage   82.38%   82.35%   -0.04%     
==========================================
  Files         120      120              
  Lines        6938     6941       +3     
  Branches     1170     1172       +2     
==========================================
  Hits         5716     5716              
- Misses       1119     1120       +1     
- Partials      103      105       +2     
Flag Coverage Δ
suite.unit 82.35% <0.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.35% <0.00%> (-0.04%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rix0rrr rix0rrr added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-codecov The PR linter will not require codecov checks to pass labels Mar 22, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 22, 2025 18:08

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 22, 2025
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

ignoreFailedLookup

vs.

The dummy value should not be returned for all SDK lookup failures. For example, "no network" or "no credentials" or "malformed query" should not lead to the dummy value being returned. Only the case of "no such resource" should.`

Why not call it ignoreResourceNotFound (or similar) then?

And then because ignore always implies you know what the standard behavior is, we might be better off calling it failOnResourceNotFound (with a value defaulting to true). Or even something like mustReturnResource.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 24, 2025
@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 24, 2025

How about mustExist ?

Copy link
Contributor

mergify bot commented Mar 25, 2025

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: d46b51d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

mergify bot commented Mar 25, 2025

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 merged commit b3187b9 into main Mar 25, 2025
16 of 20 checks passed
@mergify mergify bot deleted the huijbers/explain-contextprovider-dummy-value branch March 25, 2025 11:33
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-codecov The PR linter will not require codecov checks to pass pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants