bito-code-review[bot] commented on code in PR #36331:
URL: https://github.com/apache/superset/pull/36331#discussion_r2572374019
##########
superset-frontend/src/core/sqlLab/index.ts:
##########
@@ -73,6 +78,23 @@ const createTab = (
return new Tab(id, name, editor, panels);
};
+const getTab = (id: string): Tab | undefined => {
+ const queryEditor = findQueryEditor(id);
+ if (queryEditor) {
+ const { name, sql, dbId, catalog, schema } = queryEditor;
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Type Safety Risk in getTab</b></div>
<div id="fix">
The getTab function destructures dbId from queryEditor and uses it with a
non-null assertion (!) in createTab, but QueryEditor.dbId is optional. If dbId
is undefined, this passes undefined to createTab's required number parameter,
likely causing a runtime error. It looks like the code assumes dbId is always
set, but the type allows it to be missing.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
const { name, sql, dbId, catalog, schema } = queryEditor;
if (!dbId) return undefined;
````
</div>
</details>
</div>
<small><i>Code Review Run #f9fff1</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]