Skip to content

fix: don't fail the grid when relationship resolution exceeds the query value limit - #3143

Merged
HarshMN2345 merged 2 commits into
mainfrom
fix-grid-relationship-query-limit
Jul 31, 2026
Merged

fix: don't fail the grid when relationship resolution exceeds the query value limit#3143
HarshMN2345 merged 2 commits into
mainfrom
fix-grid-relationship-query-limit

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What

Opening a table (or collection) whose rows have wide relationships renders a full-page 400 Invalid query: Query on attribute has greater than 500 values: $id instead of the grid.

The console never sends that $id query. The grid load only sends Query.limit(50), Query.offset(0), Query.orderDesc('') and the per-relationship Query.select(['<rel>.*']) wildcards from buildWildcardEntitiesQuery. The oversized $id query is built inside the API while resolving relationships for the whole page of rows, and trips APP_DATABASE_QUERY_MAX_VALUES = 500.

Reported by a customer on project 679f1c1200137e7a62e6 (DB16), reproduced locally against cloud.

How

New loadGridRows helper in $database/store:

  1. Makes the normal request, relationship wildcards included — unchanged for every table that loads today.
  2. Only on a greater than N values failure, retries the same page with Query.select(['*']) instead of the rel.* selects, so nothing gets resolved and the request goes through.
  3. Re-fetches relationship data in chunks of 10 rows (Query.equal('$id', chunk) + wildcards) in parallel and merges by $id, preserving order. A chunk that still fails leaves those rows unpopulated rather than failing the page.

Wired into the table page load, the collection page load, and both paging paths in spreadsheet.svelte — otherwise the page would load and then break on the next page.

Note

This is a mitigation, not the fix. The real fix is server side: chunk the internal $id query used for relationship resolution, or run it under the higher internal limit. Worth tracking separately so we can drop this fallback later.

Test plan

  • bun run format && bun run check && bun run lint && bun run test:unit
  • Load the reported table in the customer's project and confirm the grid renders with relationship cells populated
  • Confirm tables without relationships and normal relationship tables are unaffected (single request, no fallback)

…ry value limit

Tables with wide relationships make the API exceed its own 500 value
limit while resolving them for a full page of rows, failing the whole
listRows request and rendering a 400 error page instead of the table.

Retry the page without relationship selects when that happens, then fill
relationships in over chunks of 10 rows. Rows whose chunk still fails
render without relationship data instead of taking down the page.
Tables that load today are unaffected - the fallback only runs after a
'greater than N values' failure.
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a relationship-resolution fallback for database grids.

  • Retries page loads without relationship expansion when the API exceeds its query-value limit.
  • Fetches relationship data in smaller batches and merges populated records by ID.
  • Applies the fallback to table, collection, and spreadsheet pagination paths.
  • Materializes spreadsheet filter queries so retries preserve active filters.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/routes/(console)/project-[region]-[project]/databases/database-[database]/store.ts Adds the shared retry and chunked relationship-population implementation.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte Uses the shared fallback for spreadsheet paging and safely reuses materialized filter queries during retries.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+page.ts Routes the initial TablesDB row load through the shared relationship fallback.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/+page.ts Routes the initial DocumentsDB collection load through the shared relationship fallback while preserving its response shape.

Reviews (2): Last reviewed commit: "fix: materialize filter queries so the r..." | Re-trigger Greptile

loadGridRows builds its queries twice on the fallback path, and loadPage
passed a Map iterator that the first build exhausted - the retry then ran
without the active filters and paged in rows outside them.
@HarshMN2345
HarshMN2345 merged commit 826bccc into main Jul 31, 2026
4 checks passed
@HarshMN2345
HarshMN2345 deleted the fix-grid-relationship-query-limit branch July 31, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants