codeant-ai-for-open-source[bot] commented on code in PR #43278:
URL: https://github.com/apache/superset/pull/43278#discussion_r3800992546
##########
superset-frontend/src/SqlLab/actions/sqlLab.ts:
##########
@@ -696,11 +706,16 @@ export function syncQueryEditor(
);
return SupersetClient.post({
endpoint: '/tabstateview/',
- postPayload: { queryEditor },
+ postPayload: {
+ queryEditor: {
+ ...queryEditorToMigrate,
+ dbId: queryEditorToMigrate.dbId ?? null,
+ },
+ },
Review Comment:
**Suggestion:** When the editor database is deleted, this normalization
allows the tab POST to succeed but still migrates every local table schema
collected above with its original deleted `dbId`. The backend creates
`TableSchema.database_id` with a non-null foreign key, so those table
migrations return 400 and the tab's schema state is lost while retries
continue. Deleted-database migrations must skip or discard the associated local
table schemas instead of migrating them unchanged. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Deleted-database schema-browser tables fail migration.
- ⚠️ Open table schemas disappear from persisted tab state.
- ⚠️ `migrateTable()` reports a warning instead of preserving state.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=57b7be7bc87b47be9bc96d9264f2d23e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=57b7be7bc87b47be9bc96d9264f2d23e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/SqlLab/actions/sqlLab.ts
**Line:** 709:714
**Comment:**
*Api Mismatch: When the editor database is deleted, this normalization
allows the tab POST to succeed but still migrates every local table schema
collected above with its original deleted `dbId`. The backend creates
`TableSchema.database_id` with a non-null foreign key, so those table
migrations return 400 and the tab's schema state is lost while retries
continue. Deleted-database migrations must skip or discard the associated local
table schemas instead of migrating them unchanged.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43278&comment_hash=3afb8836d4af1e760876aa947b4d8c49ed9ba63c5067912eea3e52ca1ca76606&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43278&comment_hash=3afb8836d4af1e760876aa947b4d8c49ed9ba63c5067912eea3e52ca1ca76606&reaction=dislike'>👎</a>
##########
superset-frontend/src/SqlLab/actions/sqlLab.ts:
##########
@@ -686,7 +686,17 @@ export function syncQueryEditor(
queryEditor: QueryEditor,
): SqlLabThunkAction<Promise<unknown>> {
return function (dispatch: AppDispatch, getState: GetState) {
- const { tables, queries } = getState().sqlLab;
+ const { tables, queries, databases } = getState().sqlLab;
+ const databaseWasRemoved =
+ queryEditor.dbId !== undefined && !databases[queryEditor.dbId];
+ const queryEditorToMigrate = databaseWasRemoved
Review Comment:
**Suggestion:** The deletion check trusts `sqlLab.databases`, but
`SET_DATABASES` merges new entries into the existing map without removing
databases that no longer exist. After a database is deleted and the database
list is refreshed, its old ID can remain present, so this condition evaluates
false and the migration still posts the deleted foreign-key ID, recreating the
endless 400 retry. Replace the membership check with an authoritative database
snapshot or remove stale entries when refreshing the database list. [cache]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Deleted-database tabs can repeatedly fail backend migration.
- ⚠️ SQL Lab auto-sync retains stale local tabs.
- ❌ Tab persistence remains blocked by the database foreign key.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=334b0224d144491db44ae12c5cca1e37&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=334b0224d144491db44ae12c5cca1e37&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/SqlLab/actions/sqlLab.ts
**Line:** 690:692
**Comment:**
*Cache: The deletion check trusts `sqlLab.databases`, but
`SET_DATABASES` merges new entries into the existing map without removing
databases that no longer exist. After a database is deleted and the database
list is refreshed, its old ID can remain present, so this condition evaluates
false and the migration still posts the deleted foreign-key ID, recreating the
endless 400 retry. Replace the membership check with an authoritative database
snapshot or remove stale entries when refreshing the database list.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43278&comment_hash=30191b9ae7a3bf036a6395b3343b2ab3f519efe8178cb9e51c72ac7839a859dd&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43278&comment_hash=30191b9ae7a3bf036a6395b3343b2ab3f519efe8178cb9e51c72ac7839a859dd&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]