Skip to content

fix(console): drop renamed or deleted columns from the saved rows select - #15117

Merged
HarshMN2345 merged 2 commits into
mainfrom
fix-console-stale-row-columns
Oct 30, 2026
Merged

HarshMN2345 merged 2 commits into
mainfrom
fix-console-stale-row-columns

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What changed

  • Rows grid: the 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 400 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 and tablesdb/Spreadsheet.tsx, so the two still share one query key. Tables without a saved layout send no select, so they were never affected.
  • Error copy: formatError matched "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

  • formatError on an AppwriteException:
    • 400 general_query_invalid → "Invalid Request" with the API message
    • 404 row_not_found → "Not Found"
    • plain Error('Table not found') (no status code) → "Not Found"
  • tsc --noEmit passes. eslint and prettier report nothing new in the changed hunks; both files already had issues on main.
  • Not tested in a browser. The grid fix wasn't run against a table with a renamed column.

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.
@appwrite

appwrite Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

New Console

Project ID: new-console

Sites (1)
Site Status Logs Preview QR
 New Console
new-console
Ready Ready View Logs Preview URL QR Code

Tip

Trigger functions via HTTP, SDKs, events, webhooks, or scheduled cron jobs

@luxor-code-review

luxor-code-review Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

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.

Files Change
apps/console/src/routes/_public/projects.$projectId.databases.$dbKind.$databaseId.tables.$tableId.rows.tsx Rows route loader intersects saved-layout keys with the prefetched columns list (available-status filter) and reuses the columns fetch for relationship keys.
apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Spreadsheet.tsx RowsSpreadsheet applies the same available-column filter to saved-layout keys via a memoized rowsSelectAttrKeys.
apps/console/src/lib/utils/error-formatting.ts Coded 400 "not found" messages now fall through to the 400 branch so the specific API message is surfaced.

Reviewed commit: 3c6cc0d

@ghost

ghost commented Oct 30, 2026 •

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The behavior change is straightforward, but it needs a regression test for stale saved column keys and loader/view query consistency.

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.”

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 Add coverage for stale saved column keys apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Spreadsheet.tsx:3342
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
File Change
apps/console/src/components/pages/projects/$projectId/databases/tablesdb/Spreadsheet.tsx Filters saved row selection keys before building both row queries.
apps/console/src/lib/utils/error-formatting.ts Restricts message-based not-found handling to errors without an HTTP status.
apps/console/src/routes/_public/projects.$projectId.databases.$dbKind.$databaseId.tables.$tableId.rows.tsx Filters saved row selection keys in the loader to align its query with the spreadsheet.

Reviewed 3c6cc0d · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

const availableColumnKeys = new Set(
apiColumns
.map((column) => column as { key?: unknown; status?: unknown })
.filter((c) => c.status === undefined || c.status === 'available')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines +195 to +208
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.

@HarshMN2345
HarshMN2345 merged commit be6588a into main Oct 30, 2026
39 of 40 checks passed
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.

1 participant