superset icon indicating copy to clipboard operation
superset copied to clipboard

SQL Lab: pasting text that matches no database into the "Data connection" select throws TypeError

Open aryan9948 opened this issue 3 days ago • 0 comments

Bug description

In SQL Lab's "Select Database and Schema" popover, pasting text that doesn't match any database into the empty "Data connection" field shows a red error overlay:

TypeError: Cannot read properties of undefined (reading 'value')

How to reproduce

  1. Open SQL Lab and click the database selector ("Select Database and Schema")
  2. Click the empty "Data connection" field
  3. Paste any text that is not a database name (e.g. abc)

Expected

No error. The pasted text should be ignored or used as a search term.

Actual

Error overlay with the TypeError above.

Not affected

  • Typing the same text
  • Pasting the exact name of an existing database (examples)
  • Pasting when a database is already selected

Stack trace (top frames)

  • changeDatabase — src/components/DatabaseSelector/index.tsx
  • eval — packages/superset-ui-core/src/components/Select/AsyncSelect.tsx (effect that calls onChange)

Possible cause

In single-select mode, onPaste in AsyncSelect.tsx calls fireOnChange() even when getPastedTextValue returns undefined. The effect then calls onChange(selectValue, options[0]) with options[0] undefined, and changeDatabase reads database.value without a guard.

I'd like to work on this. Which fix would maintainers prefer: skip fireOnChange() when the paste matched nothing, or guard changeDatabase?

Screenshots/recordings

Screenshot (42) Screenshot (43)

Superset version

master / latest-dev

Python version

Not applicable

Node version

18 or greater

Browser

Chrome

Additional context

Tested on master commit 7819e820 (Docker dev setup, docker compose).

Checklist

  • [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

aryan9948 avatar Nov 28 '26 22:11 aryan9948