AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Table Editor Drops And Re-Adds Primary Key Due To Order-Sensitive Column Name Comparison

updateTable compares primary key column names in display order with the backend's primary_keys array (which comes back in key order). A rename or an out-of-order composite primary key like (b, a) is falsely detected as a PK change, causing Studio to drop and re-add the constraint in separate transactions. This fails when a foreign key references the primary key, blocking unrelated edits, or silently rebuilds the constraint and reorders columns when no FK exists.

highConfidence 85%Supabase-Studio@supabase/supabase-jsRealtime

Origin Analysis

The PK change detection compares arrays of column names in display order against primary_keys in key order instead of comparing PK membership by column id, leading to false positives for renames and composite key ordering differences.
1. Create a table with a composite primary key (b, a) or a single primary key 'id'. 2. Create another table with a foreign key referencing that primary key. 3. Open the Table Editor and make an unrelated change (e.g., edit description) or rename a non-PK column. 4. Save; Studio erroneously drops the primary key constraint because it thinks the PK changed. 5. The save fails with 'cannot drop constraint ... other objects depend on it' if a FK exists, or silently rebuilds the PK and changes column order to (a, b) if no FK exists.

Fixing Code Block

Edge Case Audit

This fix relies on each primary key column having a stable `id` across renames; if the backend regenerates ids on rename, the comparison could still trigger false positives. Additionally, concurrent schema edits could produce stale `primary_keys` arrays, causing missed or duplicate drops. Rolling back this hotfix after upgrading would reintroduce the order-sensitivity bug for composite keys. Recommended: test with multi-column PKs and FK dependencies, and consider adding optimistic locking or schema version checks for concurrent edits.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state