Skip to content

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Jul 2, 2025

The CCAPI provider stops after the first page of results. This may cause for example EC2 Prefix Lists that exist to not be found, if they don't occur in the first page of results.

Make the provider retrieve all pages of results.

Also in this PR:

  • New SDK mocks had been added without them being added to all the places where they needed to be added to be reset properly. Instead, put them all into an object so we can do a reliable for loop that will never go out of date again.
  • Up the MaxResults to 100, so we need to do fewer paginations and the chances of the error message finding too many elements has a reasonable indicator of the number of resources actually found.

Fixes #587


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 July 2, 2025 10:06
@aws-cdk-automation aws-cdk-automation requested a review from a team July 2, 2025 10:07
@github-actions github-actions bot added p2 bug p1 and removed p2 labels Jul 2, 2025
Comment on lines 112 to 113
// eslint-disable-next-line no-console
console.log(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line no-console
console.log(result);

@rix0rrr rix0rrr force-pushed the huijbers/cc-provider-pagination branch from d459e5d to b84bdfb Compare July 2, 2025 10:15
@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.96%. Comparing base (6735323) to head (d1b762d).
⚠️ Report is 64 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #678      +/-   ##
==========================================
+ Coverage   78.94%   78.96%   +0.01%     
==========================================
  Files          46       46              
  Lines        7102     7102              
  Branches      793      797       +4     
==========================================
+ Hits         5607     5608       +1     
+ Misses       1476     1473       -3     
- Partials       19       21       +2     
Flag Coverage Δ
suite.unit 78.96% <ø> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.


// This allows us to error out early, before we have consumed all pages.
if ((expectedMatchCount === 'at-most-one' || expectedMatchCount === 'exactly-one') && found.length > 1) {
throw new ContextProviderError(`Found ${found.length} resources matching ${JSON.stringify(propertyMatch)}; expected ${expectedMatchCountText(expectedMatchCount)}. Please narrow the search criteria`);
Copy link
Contributor

Choose a reason for hiding this comment

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

The error messages is technically wrong now. Maybe something like?

Suggested change
throw new ContextProviderError(`Found ${found.length} resources matching ${JSON.stringify(propertyMatch)}; expected ${expectedMatchCountText(expectedMatchCount)}. Please narrow the search criteria`);
throw new ContextProviderError(`Found more than one resources matching ${JSON.stringify(propertyMatch)}; expected ${expectedMatchCountText(expectedMatchCount)}. Please narrow the search criteria`);

The CCAPI provider stops after the first page of results. This may cause
for example EC2 Prefix Lists that exist to not be found, if they don't
occur in the first page of results.

Make the provider retrieve all pages of results.

Also in this PR:

- New SDK mocks had been added without them being added to all the
  places where they needed to be added to be reset properly. Instead,
  put them all into an object so we can do a reliable `for` loop
  that will never go out of date again.
@rix0rrr rix0rrr force-pushed the huijbers/cc-provider-pagination branch from b84bdfb to d1b762d Compare July 2, 2025 10:29
@rix0rrr rix0rrr temporarily deployed to integ-approval July 2, 2025 10:29 — with GitHub Actions Inactive
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Jul 2, 2025
Merged via the queue into main with commit f162c19 Jul 2, 2025
32 checks passed
@aws-cdk-automation aws-cdk-automation deleted the huijbers/cc-provider-pagination branch July 2, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(context-providers): Support pagination for listresources in CCAPI

4 participants