Skip to content

Fix nested edges pagination#329

Merged
iLLiCiTiT merged 3 commits into
developfrom
bugfix/graphql_fix_truncation_over_300
May 15, 2026
Merged

Fix nested edges pagination#329
iLLiCiTiT merged 3 commits into
developfrom
bugfix/graphql_fix_truncation_over_300

Conversation

@BigRoy
Copy link
Copy Markdown
Member

@BigRoy BigRoy commented May 14, 2026

Changelog Description

Fix truncation over 300 for get_entities_links

Additional review information

This isn't the optimal fix - but it's the simplest one.

  • if an edge has nested paginated children
  • the outer edge page size becomes 1
  • so each request contains exactly one parent node
  • therefore the shared child cursor can only belong to that one parent

So instead of this broken shape:

  1. fetch parents A, B, C in one outer page
  2. parse A.links
  3. parse B.links
  4. parse C.links
  5. shared links._cursor / links._need_query gets overwritten while processing that mixed batch

it becomes:

  1. fetch parent A only
  2. finish all pagination for A.links
  3. advance outer cursor to parent B
  4. finish all pagination for B.links
  5. advance to C
  6. and so on

This means that as pagination gets involved, it'll also paginate each 'parent' entity id one by one to avoid the bug essentially.
The only other means would be to actually keep track of the cursor state of each parent when nested pagination is involved. That would need to:

  • keeps pagination state per parent instance
  • records which specific parent items still have pending child pages
  • issues a targeted follow-up query for that parent only
  • then resumes the outer connection cursor normally

It adds a lot of complexity for not having to do ALL parents one by one, but only the select few you know require pagination.

This workaround: everything becomes one-parent-at-a-time immediately
Proper fix: first query can still fetch up to 300 parents at once, and only the parents with unfinished nested pagination get replayed individually afterward

Testing notes:

  1. Truncation should not happen in the mixed 300+ with lower counts with multiple parents.

@BigRoy BigRoy requested review from Copilot and iLLiCiTiT May 14, 2026 18:42
@BigRoy BigRoy self-assigned this May 14, 2026
@BigRoy BigRoy added the type: bug Something isn't working label May 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a truncation bug in get_entities_links where shared child cursor state could be overwritten when multiple parents were fetched in the same outer page. The workaround forces one-parent-at-a-time pagination whenever a query contains nested edge fields, trading throughput for correctness.

Changes:

  • In EdgesField.get_filters, cap the outer page limit to 1 when child_has_edges is true, so each outer query returns a single parent and its child cursor cannot be clobbered.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@iLLiCiTiT iLLiCiTiT changed the title Fix possible truncation over 300 in get_entities_links Fix nested edges pagination May 15, 2026
Comment thread ayon_api/graphql.py Outdated
@iLLiCiTiT iLLiCiTiT merged commit 2cdf288 into develop May 15, 2026
3 checks passed
@iLLiCiTiT iLLiCiTiT deleted the bugfix/graphql_fix_truncation_over_300 branch May 15, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants