Repository navigation
fix(console): drop renamed or deleted columns from the saved rows select - #15117
Conversation
The rows grid builds Query.select from the column layout saved in account prefs. After a column was renamed or deleted, the select still named it and every listRows call failed with "Attribute not found in schema", so the table showed no rows. Keep only keys of available columns, in both the route loader and the grid so they share one query key.
formatError matched "not found" in any message before checking the status, so a 400 like "Invalid query: Attribute not found in schema" showed the generic Not Found copy. Only match the message when the error has no status code.
New ConsoleProject ID: Tip Trigger functions via HTTP, SDKs, events, webhooks, or scheduled cron jobs |
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change prevents stale saved-layout keys (renamed or deleted columns) from being sent to the rows list endpoint, avoiding API errors from selecting unavailable columns.
Reviewed commit: 3c6cc0d |
🔵 Tier A · Mergeable after minor fixes
The rows route loader and spreadsheet now filter saved row-selection keys against the table’s available columns. Error formatting also preserves the API message for 400 responses containing “not found.”
Fix with agent prompt### Issue 1
apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Spreadsheet.tsx:3342
**Add coverage for stale saved column keys**
The existing `database-relationship-values` tests exercise the select builder with already-valid keys, but not this new schema filter or its parity with the route loader. A regression that lets a renamed/deleted key reach `listRows`, or makes the loader and spreadsheet produce different query keys, would currently pass.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 3
Reviewed |
| const availableColumnKeys = new Set( | ||
| apiColumns | ||
| .map((column) => column as { key?: unknown; status?: unknown }) | ||
| .filter((c) => c.status === undefined || c.status === 'available') |
There was a problem hiding this comment.
Add coverage for stale saved column keys
The existing database-relationship-values tests exercise the select builder with already-valid keys, but not this new schema filter or its parity with the route loader. A regression that lets a renamed/deleted key reach listRows, or makes the loader and spreadsheet produce different query keys, would currently pass.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Spreadsheet.tsx
Line: 3342
Comment:
**Add coverage for stale saved column keys**
The existing `database-relationship-values` tests exercise the select builder with already-valid keys, but not this new schema filter or its parity with the route loader. A regression that lets a renamed/deleted key reach `listRows`, or makes the loader and spreadsheet produce different query keys, would currently pass.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
There was a problem hiding this comment.
This PR filters saved rows-grid column layouts against actually available table columns (loader and spreadsheet hook) before passing them as the rows-list Query.select, and refines a 404-style error message path in the console.
Key findings
- 🟡 Layout filter uses truncated first columns page — projects.$projectId.databases.$dbKind.$databaseId.tables.$tableId.rows.tsx:195
| const availableColumnKeys = new Set( | ||
| columns | ||
| .map((column) => column as { key?: unknown; status?: unknown }) | ||
| .filter((c) => c.status === undefined || c.status === 'available') | ||
| .map((c) => c.key), | ||
| ) | ||
| const acct = getConsoleAccountFromCache(queryClient) | ||
| const listSelectAttrKeys = | ||
| acct?.prefs && databaseId && tableId | ||
| ? parseTablesDbRowsListColumnsFromPrefs( | ||
| ? (parseTablesDbRowsListColumnsFromPrefs( | ||
| acct.prefs as Record<string, unknown>, | ||
| databaseId, | ||
| tableId, | ||
| ) | ||
| )?.filter((key) => availableColumnKeys.has(key)) ?? null) |
There was a problem hiding this comment.
🟡 bug · medium
Layout filter uses truncated first columns page
Both the rows route loader (rows.tsx:195-208) and RowsSpreadsheet (Spreadsheet.tsx:3339-3348) filter saved-layout keys against availableColumnKeys built from the columns list, but that list is fetched with the default limit: COLUMNS_INDEXES_DEFAULT_PAGE_SIZE (100). For a table with more than 100 columns, keys of columns beyond the first page are absent from the set and get silently dropped from listSelectAttrKeys, so buildRowListSelectQuery omits them and those columns render empty even though they are valid and selectable. This is a silent data-loss-in-UI regression on the new filtering path.
📋 Prompt for AI Agents
In apps/console/src/routes/_public/projects.$projectId.databases.$dbKind.$databaseId.tables.$tableId.rows.tsx (lines ~195-208) and apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Spreadsheet.tsx (lines ~3339-3348), the saved-layout select filter intersects rowsListSelectAttrKeys with the keys of the columns returned by tableColumnsQueryOptions/useProjectTableColumns, which are limited to COLUMNS_INDEXES_DEFAULT_PAGE_SIZE (100) rows. For tables with more than 100 columns, valid saved-layout keys beyond the first page are dropped from the rows Query.select, so those columns show no data. Fix: derive availableColumnKeys from the complete column set — e.g. check the query's total and, when total > columns.length, fetch remaining pages or fall back to not filtering — applying identical logic in both the loader and the hook so they keep producing the same query key.

What changed
Query.selectfrom the column layout saved in account prefs. After a column was renamed or deleted, the select still named it, and everylistRowscall failed with400 general_query_invalid: Attribute not found in schema: <key>. Saved keys are now kept only if they match an available column, in both the rows route loader andtablesdb/Spreadsheet.tsx, so the two still share one query key. Tables without a saved layout send no select, so they were never affected.formatErrormatched "not found" in any message before it checked the status code, so that 400 showed "Not Found… may have been deleted or you may not have permission". It now matches on the message only when the error has no status code, so the 400 shows the API's message.Tested
formatErroron anAppwriteException:general_query_invalid→ "Invalid Request" with the API messagerow_not_found→ "Not Found"Error('Table not found')(no status code) → "Not Found"tsc --noEmitpasses. eslint and prettier report nothing new in the changed hunks; both files already had issues on main.