Skip to content

into sqlite errors don't mark the into sqlite line #15410

@ghost

Description

Describe the bug

into sqlite does not include the into sqlite in the error-message (i assume a span is missing)

Error: nu::shell::eval_block_with_input

  × Eval block failed with pipeline input
    ╭─[/home/shae/git/twitchlistener/sqlite/to_sqlite.nu:27:3]
 26 │ def chat [sql_file: path]: nothing -> nothing {
 27 │   ls *.txt.gz
    ·   ─┬
    ·    ╰── source value
 28 │   | get name
    ╰────

Error:
  × Failed to execute SQLite statement
related code

(this parses IRC logs and dumps them into a sqlite db)

def chat [sql_file: path]: nothing -> nothing {
  ls *.txt.gz
  | get name
  | par-each {|i|
    print $'CHAT ($i)'
    ^gunzip -kdc $i
    | lines
    | parse -r '^(?P<timestamp>\d+) <<< [^ ]*first-msg=(?P<first_msg>[01])[^ ]* :(?P<author>[^!]+)[^ ]+ PRIVMSG #(?P<room>[^ ]+) :(?P<msg>.*)$'
    | update timestamp {|i| $i.timestamp | into datetime -f %s}
    | update first_msg {|i| $i.first_msg == "1"}
    | into sqlite -t messages $sql_file
    null
  }
  null
}

the error was caused by the par-each (probably a race-condition? but it was thrown by the last process seconds after the previous one finished -- anyway unrelated issue)

in my case i knew where the error came from, but in a older revision i would not:

let a = open irc_logs.txt

$a
| some_processing
| into sqlite -t messages my.db

$a
| different_processing
| into sqlite -t user_status_updates my.db

How to reproduce

  1. create a issue with into sqlite
  2. check the error message

example code, which can reliable recreate the issue:

0..100
| par-each {|i|
  0..1000
  | each {|i| {"foo": "bar"} }
  | into sqlite -t test test.sqlite
}

Expected behavior

I expect both a source and a error-location similar to all the other commands:

Error: nu::shell::column_not_found

  × Cannot find column 'wrong_columns'
   ╭─[entry #1:1:1]
 1 │ ls | update wrong_columns {|| foo}
   · ─┬          ──────┬──────
   ·  │                ╰── cannot find column 'wrong_columns'
   ·  ╰── value originates here
   ╰────

Configuration

key value
version 0.103.1
major 0
minor 103
patch 1
branch main
commit_hash bf1f2d5
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.83.0 (90b35a623 2024-11-26)
rust_channel 1.83.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.83.0 (5ffbef321 2024-10-29)
build_time 2025-03-25 02:52:25 +01:00
build_rust_channel release
allocator standard
features default, sqlite, trash
installed_plugins explore 0.100.0, nups2 0.101.0, python_example 0.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-unhelpfulThe error message you observe is not helpful to identify the problemcategory:bugSomething isn't workingstatus:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions