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

Relation Resolution - stringifiedStoriesCache prevents resolution of 1st level story relation if the story is also a 2nd level/nested relation #856

Open
lakeboerg opened this issue Sep 19, 2024 · 0 comments
Assignees
Labels
bug Something isn't working help wanted [Contribution] Extra attention is needed p2-edge-case [Priority] Bugs with workarounds or limited impact. PR welcome [Contribution] Pull requests are welcome.

Comments

@lakeboerg
Copy link

Dear storyblok client team,

it's a pleasure to interact with your libs and I want to thank you for your work.
And while doing so, I ran into a rather particular issue. A little deep-dive into the relations resolution mechanism yielded a funny issue.

Could be an edge-case scenario, however we ran into it and I think it is not so "edge-casy" after all.

Let's go:

stringifiedStoriesCache prevents resolution of 1st level story relation if the story is also a 2nd level/nested relation.

Expected Behavior

All found relations should be fully processed for relation resolution, regardless whether it is used as a nested/2nd level relation.

Current Behavior

If the relation is used as a 2nd level/nested relation in a 1st level relation, the 1st level relations won't be resolved because the stringifiedStoriesCache returns the API provided, non resolved item due to the first 2nd level relation resolution.

Important
It depends on the order of keys of this.relatations in resolveStories which story gets processed and cached eagerly.

Steps to Reproduce

Required data- and relation-structure:

+ story-1 refs
    - story-2 refs
        - story-432
    - story-3 refs
        - story-432
        - story-4
    - story-4 refs
        - story-432 
    - story-5 refs
        - story-432

The API correctly returns all relations:

  • story-2
  • story-3
  • story-4
  • story-5
  • story-432

Now when within resolveStories the code iterates over relations and passes every relation object into iterateTree to resolve AND story-3 is iterated earlier than story-4, the resolution of story-4 as a relation of story-3 leads to getStoryReference to store the non-resolved, API provided story-4 in the stringifiedCache.

Now story-4 gets processed to resolve it's relations, but story-432's relations can't be resolved, because it is already in the stringifiedCache.

I am happy to help out in any case.

Looking forward to a reply and best regards,

l

@alvarosabu alvarosabu added the pending-triage [Issue] Ticket is pending to be prioritised label Oct 1, 2024
@alvarosabu alvarosabu self-assigned this Oct 1, 2024
@alvarosabu alvarosabu added bug Something isn't working help wanted [Contribution] Extra attention is needed p2-edge-case [Priority] Bugs with workarounds or limited impact. PR welcome [Contribution] Pull requests are welcome. and removed pending-triage [Issue] Ticket is pending to be prioritised labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted [Contribution] Extra attention is needed p2-edge-case [Priority] Bugs with workarounds or limited impact. PR welcome [Contribution] Pull requests are welcome.
Projects
None yet
Development

No branches or pull requests

2 participants