Conversation
Head branch was pushed to by a user without write access
rix0rrr
left a comment
There was a problem hiding this comment.
I agree with you that persisting a 0-length array may make it harder to recover from problems in the future.
But I don't agree that a >=1 length array is automatically a failure. It is up the lookup method to reject >=1 element if it is expecting exactly one. It is not up to the provider to say "I will never support looking up more than one resource". For example, securitygroups associated with another resource are a perfectly legit resource to look up.
For your issue:
- It is the job of
PrefixList.fromLookup()to handle the >=1 case. - As for the 0 results case: we can fail the provider, that's an easy way of making sure that the 0-length array is not persisted. To achieve that, we should add an additional field into the query that indicates that a 0-element list should be considered an error.
|
@rix0rrr Thank you for clarification. I've pushed following updates:
Current PRs using CC API Context Provider, except for my PrefixList, use |
CcApiContextProviderPluginCcApiContextProviderPlugin
packages/@aws-cdk/cloud-assembly-schema/lib/cloud-assembly/context-queries.ts
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #251 +/- ##
==========================================
+ Coverage 85.24% 85.40% +0.15%
==========================================
Files 222 222
Lines 36898 36926 +28
Branches 4438 4454 +16
==========================================
+ Hits 31455 31535 +80
+ Misses 5348 5296 -52
Partials 95 95
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I'm going to wait for #211 to be in, then refactor this PR a bit on top of that other one. They're too uncomfortably close for me so I'm taking the reins to make them play nicely together. |
|
Ok, thanks for adjustment! |
…g does not find a specific count of resources (#251) Fixes #257 As described in the issue, `CcApiContextProviderPlugin` should have the way to ensure the result has exact one resource. This PR adds the `expectedMatchCount` option to restrict the length of results in `listResources()`. Unit tests are added and modified ensure the changes. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Co-authored-by: Rico Huijbers <rix0rrr@gmail.com>
…m CcApi context provider has exactly one resource (#34199) ### Issue # (if applicable) Follow-up to #33619. ### Reason for this change CcApi context provider now can expect the matched count of resources: aws/aws-cdk-cli#251. `PrefixList.fromLookup()` is needed to be updated using this feature not to persist invalid results in `cdk.context.json`. See also aws/aws-cdk-cli#257. ### Description of changes - Bumped `@aws-cdk/cloud-assembly-schema` to latest ^43.6.0. - Specify `expectedMatchCount: 'exactly-one'` to expect exactly one prefix list id is returned. - Updated validation to check unexpected result. Actual error will be returned from the context provider. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Updated integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…m CcApi context provider has exactly one resource (#34565) Re-creation of #34199 A jsii related issue #34199 (comment) should be fixed before merging this PR. ### Issue # (if applicable) Follow-up to #33619. ### Reason for this change CcApi context provider now can expect the matched count of resources: aws/aws-cdk-cli#251. `PrefixList.fromLookup()` is needed to be updated using this feature not to persist invalid results in `cdk.context.json`. See also aws/aws-cdk-cli#257. ### Description of changes - Bumped `@aws-cdk/cloud-assembly-schema` to latest ^44.1.0. - Specify `expectedMatchCount: 'exactly-one'` to expect exactly one prefix list id is returned. - Updated validation to check unexpected result. Actual error will be returned from the context provider. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Updated integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Fixes #257
As described in the issue,
CcApiContextProviderPluginshould have the way to ensure the result has exact one resource.This PR adds the
expectedMatchCountoption to restrict the length of results inlistResources().Unit tests are added and modified ensure the changes.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license