tconbeer / harlequin

The SQL IDE for Your Terminal.
https://harlequin.sh
MIT License
3.3k stars 76 forks source link

Crash when executing a query #579

Closed mariusmuja closed 1 week ago

mariusmuja commented 1 week ago

I was trying to execute (or re-execute) a query and I had harlequin crash with the stack trace below. I'm not able to reproduce it just now, but it happened a few times today.

harlequin, version 1.6.0

Installed Adapters:
  - duckdb, version 1.6.0
  - sqlite, version 1.6.0
╭─────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────╮
│ /home/marius/.venvs/pyston/lib/python3.8-pyston2.3/site-packages/harlequin/app.py:187 in on_code_editor_submitted                │
│                                                                                                                                  │
│   184 │                                                                                                                          │
│   185 │   def on_code_editor_submitted(self, message: CodeEditor.Submitted) -> None:                                             │
│   186 │   │   message.stop()                                                                                                     │
│ ❱ 187 │   │   self.query_text = self._get_query_text()                                                                           │
│   188 │                                                                                                                          │
│   189 │   def on_data_catalog_node_submitted(                                                                                    │
│   190 │   │   self, message: DataCatalog.NodeSubmitted[CatalogItem]                                                              │
│                                                                                                                                  │
│ ╭──────────────────────────── locals ────────────────────────────╮                                                               │
│ │ message = Submitted()                                          │                                                               │
│ │    self = Harlequin(title='Harlequin', classes={'-dark-mode'}) │                                                               │
│ ╰────────────────────────────────────────────────────────────────╯                                                               │
│                                                                                                                                  │
│ /home/marius/.venvs/pyston/lib/python3.8-pyston2.3/site-packages/harlequin/app.py:491 in _get_query_text                         │
│                                                                                                                                  │
│   488 │   def _get_query_text(self) -> str:                                                                                      │
│   489 │   │   return (                                                                                                           │
│   490 │   │   │   self._validate_selection()                                                                                     │
│ ❱ 491 │   │   │   or self.editor.current_query                                                                                   │
│   492 │   │   │   or self.editor.previous_query                                                                                  │
│   493 │   │   )                                                                                                                  │
│   494                                                                                                                            │
│                                                                                                                                  │
│ ╭────────────────────────── locals ───────────────────────────╮                                                                  │
│ │ self = Harlequin(title='Harlequin', classes={'-dark-mode'}) │                                                                  │
│ ╰─────────────────────────────────────────────────────────────╯                                                                  │
│                                                                                                                                  │
│ /home/marius/.venvs/pyston/lib/python3.8-pyston2.3/site-packages/harlequin/components/code_editor.py:55 in current_query         │
│                                                                                                                                  │
│    52 │   │   before = Cursor(0, 0)                                                                                              │
│    53 │   │   after: Union[None, Cursor] = None                                                                                  │
│    54 │   │   for c in semicolons:                                                                                               │
│ ❱  55 │   │   │   if c <= self.cursor:                                                                                           │
│    56 │   │   │   │   before = c                                                                                                 │
│    57 │   │   │   elif after is None and c > self.cursor:                                                                        │
│    58 │   │   │   │   after = c                                                                                                  │
│                                                                                                                                  │
│ ╭───────────────────────── locals ─────────────────────────╮                                                                     │
│ │      after = None                                        │                                                                     │
│ │     before = Cursor(lno=37, pos=2, pref_pos=None)        │                                                                     │
│ │          c = Cursor(lno=39, pos=23, pref_pos=None)       │                                                                     │
│ │       self = CodeEditor(id='buffer-1')                   │                                                                     │
│ │ semicolons = [                                           │                                                                     │
│ │              │   Cursor(lno=0, pos=80, pref_pos=None),   │                                                                     │
│ │              │   Cursor(lno=8, pos=1, pref_pos=None),    │                                                                     │
│ │              │   Cursor(                                 │                                                                     │
│ │              │   │   lno=12,                             │                                                                     │
│ │              │   │   pos=112,                            │                                                                     │
│ │              │   │   pref_pos=None                       │                                                                     │
│ │              │   ),                                      │                                                                     │
│ │              │   Cursor(lno=15, pos=40, pref_pos=None),  │                                                                     │
│ │              │   Cursor(lno=17, pos=45, pref_pos=None),  │                                                                     │
│ │              │   Cursor(lno=20, pos=49, pref_pos=None),  │                                                                     │
│ │              │   Cursor(lno=21, pos=56, pref_pos=None),  │                                                                     │
│ │              │   Cursor(lno=23, pos=98, pref_pos=None),  │                                                                     │
│ │              │   Cursor(lno=26, pos=46, pref_pos=None),  │                                                                     │
│ │              │   Cursor(lno=29, pos=91, pref_pos=None),  │                                                                     │
│ │              │   ... +4                                  │                                                                     │
│ │              ]                                           │                                                                     │
│ ╰──────────────────────────────────────────────────────────╯                                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: '<=' not supported between instances of 'NoneType' and 'int'
mariusmuja commented 1 week ago

Oh, I noticed that my harlequin version is a few versions old, updating now and will close this issue if I cannot replicate it...

tconbeer commented 1 week ago

Let me know if you're able to repro on a current version. Closing for now.