Skip to content

Conversation

@YousufFFFF
Copy link
Contributor

@YousufFFFF YousufFFFF commented Dec 22, 2025

User description

Summary

Fixes an error during CSV upload when the frontend sends an empty or "undefined" schema value.

What changed

  • Treat empty or "undefined" schema as no schema
  • Let the database apply its default schema instead
  • Prevents InvalidSchemaName errors during CSV upload

###Demo

#Before:
image

#After:

localhost_8088_superset_welcome_.-.Google.Chrome.2025-12-22.16-57-38.mp4

Reproduction

  1. Upload CSV
  2. Leave schema empty
  3. Upload previously failed, now succeeds

CodeAnt-AI Description

Handle empty or "undefined" schema values during CSV upload so database defaults are used

What Changed

  • If the uploaded CSV specifies an empty string or the literal "undefined" for schema, the uploader now treats that as no schema and lets the database apply its default
  • A warning is logged when this fallback occurs to aid debugging
  • Prevents failures during CSV upload caused by invalid or frontend-sent "undefined" schema values

Impact

✅ Fewer CSV upload failures when schema is blank
✅ Successful uploads when frontend sends "undefined" for schema
✅ Clearer logs for schema-related upload fallbacks

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Dec 22, 2025

Code Review Agent Run #c6f16f

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/commands/database/uploaders/base.py - 1
    • Schema validation timing issue · Line 162-168
      The schema normalization logic treats 'undefined' as None, but it runs after self.validate(). Since validate() checks schema permissions via schema_allows_file_upload(), if schema restrictions exist and 'undefined' isn't allowed, uploads will fail validation unnecessarily. Move this normalization before validate() to ensure consistent handling.
Review Details
  • Files reviewed - 1 · Commit Range: 0d1bf36..0d1bf36
    • superset/commands/database/uploaders/base.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the data:csv Related to import/export of CSVs label Dec 22, 2025
@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Dec 22, 2025
@codeant-ai-for-open-source
Copy link
Contributor

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Validation ordering
    The new schema-normalization (treating empty/"undefined" as None) happens after calling self.validate(). Because validate() calls schema_allows_file_upload(self._model, self._schema) using the original self._schema, requests where the frontend sends empty/"undefined" may be rejected before the normalization occurs. Consider normalizing the schema before validation so the permission check and subsequent logic use the intended schema value.

  • Schema normalization robustness
    The added check only compares literally to the string "undefined" and treats falsy values as empty. It doesn't handle whitespace-only strings, different casing (e.g., "Undefined"), or other common tokens like "null". This can lead to unexpected behavior if the frontend sends one of those variants. Normalize the schema string (strip + lower) and check a small set of sentinel values.

return

# Treat empty or frontend-sent "undefined" schema as no schema
if not self._schema or self._schema == "undefined":
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Edge case: the current check if not self._schema or self._schema == "undefined": does not treat whitespace-only schema values or case variations (e.g., " ", "Undefined") as empty/undefined and may pass an invalid schema through; trim and do a case-insensitive check before deciding to treat it as absent. [possible bug]

Severity Level: Critical 🚨

Suggested change
if not self._schema or self._schema == "undefined":
if self._schema is None or (
isinstance(self._schema, str)
and (self._schema.strip() == "" or self._schema.strip().lower() == "undefined")
):
Why it matters? ⭐

This is a practical hardening: the current check misses whitespace-only strings and case variants like "Undefined". Using .strip() and a case-insensitive comparison avoids passing invalid values through as real schema names. It fixes a real edge case that can cause confusing validation or DB lookups.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/commands/database/uploaders/base.py
**Line:** 163:163
**Comment:**
	*Possible Bug: Edge case: the current check `if not self._schema or self._schema == "undefined":` does not treat whitespace-only schema values or case variations (e.g., `"  "`, `"Undefined"`) as empty/undefined and may pass an invalid schema through; trim and do a case-insensitive check before deciding to treat it as absent.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI finished reviewing your PR.

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.10%. Comparing base (c0bcf28) to head (0d1bf36).

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #36792       +/-   ##
===========================================
+ Coverage        0   68.10%   +68.10%     
===========================================
  Files           0      640      +640     
  Lines           0    47633    +47633     
  Branches        0     5202     +5202     
===========================================
+ Hits            0    32442    +32442     
- Misses          0    13911    +13911     
- Partials        0     1280     +1280     
Flag Coverage Δ
hive 43.04% <0.00%> (?)
mysql 66.11% <66.66%> (?)
postgres 66.16% <100.00%> (?)
presto 46.64% <0.00%> (?)
python 68.07% <100.00%> (?)
sqlite 65.87% <66.66%> (?)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:csv Related to import/export of CSVs size/XS size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant