bito-code-review[bot] commented on PR #40037:
URL: https://github.com/apache/superset/pull/40037#issuecomment-4424419869
<!-- Bito Reply -->
The flagged issue is correct—the double type assertion hides a mismatch
between the thunk's declared return type ({ id: number }) and the actual API
response ({ table_id: number }), leading to undefined datasource IDs. To
resolve, remove the cast, update the thunk return type to Promise<{ table_id:
number }>, adjust createDatasourceSuccess to use table_id, and access
data.table_id in the component. No other comments found in the PR.
**superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx**
```
const visualize = () => {
dispatch(createCtasDatasource(buildVizOptions))
.then(data => {
const formData = {
datasource: `${data.table_id}__table`,
metrics: ['count'],
```
**superset-frontend/src/SqlLab/actions/sqlLab.ts**
```
export const createCtasDatasource =
(buildVizOptions: BuildVizOptions): SqlLabThunkAction<Promise<{ table_id:
number }>> =>
async dispatch => {
// ... existing code ...
return json.result;
};
```
**superset-frontend/src/SqlLab/actions/sqlLab.ts**
```
export const createDatasourceSuccess =
(data: { table_id: number }) =>
({
type: CREATE_DATASOURCE_SUCCESS,
payload: {
datasource: `${data.table_id}__table`,
},
});
```
--
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]