Skip to content

table panics on a certain string #14910

Open
@weirdan

Description

Describe the bug

table (and table -e panics when given the following record:

{val: (0x[1b 5b 33 37 6d e2 94 82 1b] | decode)} | table

table backtrace:

Error:
  × Main thread panicked.
  ├─▶ at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/papergrid-0.12.0/src/util/string.rs:46:27
  ╰─▶ byte index 11 is not a char boundary; it is inside '│' (bytes 10..13) of `│`
         0: 0x55903a142274 - rust_begin_unwind
         1: 0x55903923dea3 - core::panicking::panic_fmt::h3d8fc78294164da7
         2: 0x5590393127cd - core::str::slice_error_fail_rt::h23607b8a3a6c2267
         3: 0x55903923e5fa - core::str::slice_error_fail::h402ef64b20c243ef
         4: 0x559039fb8e9e - <core::iter::adapters::map::Map<I,F> as
      core::iter::traits::iterator::Iterator>::fold::hb29d8b87b81d9ae7
         5: 0x559039fb487b - papergrid::util::string::get_text_width::hfb3e198311742c10
         6: 0x55903a19da2b - papergrid::records::vec_records::cell_info::create_cell_info::h1f0803f497af57c9
         7: 0x559039f7a455 - nu_table::types::general::JustTable::kv_table::h10d3e1187aa0251a
         8: 0x5590398a8b39 - nu_command::viewers::table::handle_record::h07f71e65069fbce6
         9: 0x5590398a5dcf - <nu_command::viewers::table::Table as
      nu_protocol::engine::command::Command>::run::hc8a7b88e4fdbc2da
        10: 0x559039a2cc2f - nu_engine::eval_ir::eval_call::h5c4e90d50df311c6
        11: 0x559039a2476e - nu_engine::eval_ir::eval_instruction::h93d06aaa037c4474
        12: 0x559039a2153a - nu_engine::eval_ir::eval_ir_block_impl::h0040e4214972ec30
        13: 0x559039a20847 - nu_engine::eval_ir::eval_ir_block::h5dc0ca957d356a53
        14: 0x559039a1a4a9 - nu_engine::eval::eval_block::hb26e41d26a6ac6c9
        15: 0x55903946343e - nu_cli::util::eval_source::h6de501b92206be00
        16: 0x5590394b5aec - nu_cli::repl::do_run_cmd::hdd6d70c277887c60
        17: 0x5590394bf17a - nu_cli::repl::loop_iteration::h864c67a9a562d60d
        18: 0x5590394b8209 - std::panic::catch_unwind::hdd93cbc85a5fb1d0
        19: 0x5590394b2fa6 - nu_cli::repl::evaluate_repl::hb4de108a168a10f6
        20: 0x55903942c7a1 - nu::run::run_repl::he7fca888ca2f1b55
        21: 0x559039419c59 - nu::main::h2f7213a295c7ffc4
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.

table -e backtrace:

Error:
  × Main thread panicked.
  ├─▶ at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/papergrid-0.12.0/src/util/string.rs:46:27
  ╰─▶ byte index 11 is not a char boundary; it is inside '│' (bytes 10..13) of `│`
         0: 0x55903a142274 - rust_begin_unwind
         1: 0x55903923dea3 - core::panicking::panic_fmt::h3d8fc78294164da7
         2: 0x5590393127cd - core::str::slice_error_fail_rt::h23607b8a3a6c2267
         3: 0x55903923e5fa - core::str::slice_error_fail::h402ef64b20c243ef
         4: 0x559039fb8e9e - <core::iter::adapters::map::Map<I,F> as
      core::iter::traits::iterator::Iterator>::fold::hb29d8b87b81d9ae7
         5: 0x559039fb487b - papergrid::util::string::get_text_width::hfb3e198311742c10
         6: 0x55903a19da2b - papergrid::records::vec_records::cell_info::create_cell_info::h1f0803f497af57c9
         7: 0x559039f784cd - tabled::builder::table_builder::create_row::hc3cccaabf7be8bfc
         8: 0x559039f78683 - tabled::builder::table_builder::Builder::push_record::h4ff32017da0da0db
         9: 0x559039f77b7a - <tabled::builder::table_builder::Builder as
      core::iter::traits::collect::FromIterator<R>>::from_iter::h1bcd9fad81b51d07
        10: 0x559039f74cee - nu_table::util::string_wrap::h69ee44be9db858ae
        11: 0x559039f6e78f - nu_table::types::expanded::expanded_table_kv::h25b57365810b2bde
        12: 0x559039f6c282 - nu_table::types::expanded::ExpandedTable::build_map::h95be8bb4e82c1b92
        13: 0x5590398a8beb - nu_command::viewers::table::handle_record::h07f71e65069fbce6
        14: 0x5590398a5dcf - <nu_command::viewers::table::Table as
      nu_protocol::engine::command::Command>::run::hc8a7b88e4fdbc2da
        15: 0x559039a2cc2f - nu_engine::eval_ir::eval_call::h5c4e90d50df311c6
        16: 0x559039a2476e - nu_engine::eval_ir::eval_instruction::h93d06aaa037c4474
        17: 0x559039a2153a - nu_engine::eval_ir::eval_ir_block_impl::h0040e4214972ec30
        18: 0x559039a20847 - nu_engine::eval_ir::eval_ir_block::h5dc0ca957d356a53
        19: 0x559039a1a4a9 - nu_engine::eval::eval_block::hb26e41d26a6ac6c9
        20: 0x55903946343e - nu_cli::util::eval_source::h6de501b92206be00
        21: 0x5590394b5aec - nu_cli::repl::do_run_cmd::hdd6d70c277887c60
        22: 0x5590394bf17a - nu_cli::repl::loop_iteration::h864c67a9a562d60d
        23: 0x5590394b8209 - std::panic::catch_unwind::hdd93cbc85a5fb1d0
        24: 0x5590394b2fa6 - nu_cli::repl::evaluate_repl::hb4de108a168a10f6
        25: 0x55903942c7a1 - nu::run::run_repl::he7fca888ca2f1b55
        26: 0x559039419c59 - nu::main::h2f7213a295c7ffc4
  help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.

How to reproduce

{val: (0x[1b 5b 33 37 6d e2 94 82 1b] | decode)} | table

Expected behavior

No panic. The terminal may get messed up because of the ansi sequences present in the data, but that's expected.

Configuration

key value
version 0.101.0
major 0
minor 101
patch 0
branch
commit_hash fb26109
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.81.0 (eeb90cda1 2024-09-04)
rust_channel 1.81.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.81.0 (2dbb1af80 2024-08-20)
build_time 2024-12-22 15:47:14 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, static-link-openssl, trash
installed_plugins formats 0.101.0, gstat 0.101.0, inc 0.101.0, plotters 0.1.2+0.100.0, polars 0.101.0, query 0.101.0

Metadata

Assignees

No one assigned

    Labels

    needs-triageAn issue that hasn't had any proper looktabledIssues about our new table renderer (tabled)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions