korbit-ai[bot] commented on code in PR #32218:
URL: https://github.com/apache/superset/pull/32218#discussion_r1950645361


##########
superset-frontend/src/components/Datasource/utils.js:
##########
@@ -121,7 +121,7 @@ export function updateColumns(prevCols, newCols, 
addSuccessToast) {
 
 export async function fetchSyncedColumns(datasource) {
   const params = {
-    datasource_type: datasource.type,
+    datasource_type: datasource.type || datasource.datasource_type,

Review Comment:
   ### Missing Validation for Required Datasource Type <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The fallback logic lacks null checking, which could still result in 
undefined being assigned to datasource_type if both properties are null.
   
   ###### Why this matters
   If both datasource.type and datasource.datasource_type are null, the 
parameter will be null, potentially causing issues with the API endpoint that 
expects a valid datasource type.
   
   ###### Suggested change ∙ *Feature Preview*
   Add validation to ensure a valid datasource type is always provided:
   ```javascript
   const sourceType = datasource.type || datasource.datasource_type;
   if (!sourceType) {
     throw new Error('Datasource type is required');
   }
   params = {
     datasource_type: sourceType,
     // ... rest of the params
   };
   ```
   
   
   </details>
   
   <sub>
   
   [![Report a problem with this 
comment](https://img.shields.io/badge/Report%20a%20problem%20with%20this%20comment-gray.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWVjMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10cmlhbmdsZS1hbGVydCI+PHBhdGggZD0ibTIxLjczIDE4LTgtMTRhMiAyIDAgMCAwLTMuNDggMGwtOCAxNEEyIDIgMCAwIDAgNCAyMWgxNmEyIDIgMCAwIDAgMS43My0zIi8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4=)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/ba918717-e5cb-421c-97a0-bb8ae69a0c5e?suggestedFixEnabled=true)
   
   💬 Chat with Korbit by mentioning @korbit-ai.
   </sub>
   
   <!--- korbi internal id:4f098f06-c474-4e78-9cda-d1f1aea63759 -->
   



-- 
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]

Reply via email to