Skip to content
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

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

tahvane1
Copy link
Contributor

@tahvane1 tahvane1 commented Feb 11, 2025

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

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link

@korbit-ai korbit-ai bot left a 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
Functionality 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,
Copy link

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

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
};

Report a problem with this comment

💬 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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fisjac Are these fields the same thing and we should consolidate them? I'm asking because of #30903.

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

@sadpandajoe sadpandajoe left a 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.

@sadpandajoe sadpandajoe merged commit 9da3095 into apache:master Feb 14, 2025
56 checks passed
@michael-s-molina michael-s-molina added the v5.0 Label added by the release manager to track PRs to be included in the 5.0 branch label Feb 14, 2025
michael-s-molina pushed a commit that referenced this pull request Feb 14, 2025
…ns (#32218)

Co-authored-by: Erkka Tahvanainen <erkka.tahvanainen@confidently.fi>
(cherry picked from commit 9da3095)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS v5.0 Label added by the release manager to track PRs to be included in the 5.0 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants