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

Aperta Adatta ai principianti
#46,691 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Leggi src/components/DatabaseSelector/index.tsx e packages/superset-ui-core/src/components/Select/AsyncSelect.tsx, concentrandoti su changeDatabase, onPaste e fireOnChange. Riproduci il problema incollando testo non corrispondente nel campo vuoto «Data connection» di SQL Lab. La modifica è completa quando l’incolla non causa più il TypeError e il testo non corrispondente viene ignorato o trattato soltanto come termine di ricerca; aggiungi o aggiorna il test frontend pertinente se il repository dispone di copertura per questi componenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

#bug
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.
  • 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.
Lingua principale
Python
Stelle
75.6k
Fork
18.6k
Merge medio
4g 2h
PR unite (30g)
469

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/superset

Tutte le issue di apache/superset

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.