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 broken populate traversal with no fragment #16109

Merged
merged 2 commits into from Mar 16, 2023

Conversation

Convly
Copy link
Member

@Convly Convly commented Mar 16, 2023

What does it do?

Actual fix here, the rest of the changes are tests added to check we don't have this regression in the future

Prevent recursion on undefined populate fragment values upon populate traversal (during query sanitization)

Why is it needed?

Null & undefined values for the populate fragment upon query traversal cause the traversal to throw due to an unexpected Object.entries operation on an undefined value.

How to test it?

Using the API integration tests:
yarn test:api packages/core/strapi/tests/api/sanitize/sanitize-query.test.api.js

Or by starting the getstarted app, creating a new restaurant entity from the content manager, then heading to the content API and trying to access this URL
http://localhost:1337/api/restaurants?populate[dz][populate]=*
It should return you the restaurant and the content of its dynamic zone populated (at the second level)

Related issue(s)/PR(s)

fix #16105

@Convly Convly added source: core:strapi Source is core/strapi package pr: fix This PR is fixing a bug labels Mar 16, 2023
@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@a9d1afd). Click here to learn what that means.
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16109   +/-   ##
=======================================
  Coverage        ?   59.95%           
=======================================
  Files           ?     1484           
  Lines           ?    37346           
  Branches        ?     7488           
=======================================
  Hits            ?    22389           
  Misses          ?    12769           
  Partials        ?     2188           
Flag Coverage Δ
back 50.06% <0.00%> (?)
front 66.21% <ø> (?)
unit_back 50.06% <0.00%> (?)
unit_front 66.21% <ø> (?)

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

Impacted Files Coverage Δ
packages/core/utils/lib/traverse/query-populate.js 9.70% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

LGTM!

  • local tests pass and also tested manually

@Convly Convly merged commit 4fac1b6 into main Mar 16, 2023
@Convly Convly deleted the fix/traverse-populate-with-no-fragment branch March 16, 2023 16:30
@Convly Convly added this to the 4.8.2 milestone Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: core:strapi Source is core/strapi package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to 4.8.x got error when populate dynamic component
2 participants