Skip to content

Unhelpful error: "cannot find column" when only some of the entries are missing the column #17448

Open

Description

@forder0000

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

sort shows a "cannot find column" error but when I run the command without piping it into sort I can see a name column in the result.

How to reproduce

I have encountered the issue while trying to format a cargo test output using the command bellow. Once I add a where type == "test" eliminating suites the command passes with no issues.

To reproduce, run the command on any codebase with at least one integration test (I could provide a link to the specific repo I run it on but it's probably unnecesarry)

cargo +nightly test -- --format json -Z unstable-options
| lines
| each { from json }
| sort-by name

Expected behavior

A more explicit error message: column not present for some entries

Configuration

key value
version 0.109.1
major 0
minor 109
patch 1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.92.0 (ded5c06cf 2025-12-08) (built from a source tarball)
cargo_version cargo 1.92.0 (344c4567c 2025-10-21)
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator standard
features default, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins
experimental_options example=false, reorder-cell-paths=true, pipefail=false, enforce-runtime-annotations=false

Activity

  1. added
    status:needs-triage
    on Jan 28, 2026
  2. forder0000 commented on Jan 28, 2026

    @forder0000
    Author

    One thing I only now noticed is that even though I'm on the latest version available through nix pkgs unstable (which I assumed would be at least the last stable release), it's only 0.109.1 not 0.110.0, my bad.

    I tried to reproduce it on a podman image "ghcr.io/nushell/nushell:latest" ( v0.110.0 ) and it's still occuring

  3. fdncred commented on Jan 28, 2026

    @fdncred
    Contributor

    What if you do this? note the end question mark which makes it optional

    cargo +nightly test -- --format json -Z unstable-options
    | lines
    | each { from json }
    | sort-by name?
  4. forder0000 commented on Jan 29, 2026

    @forder0000
    Author

    Yeah, then it works just fine. The 'name' field is present even after the sort.
    Though that doesn't really solve the issue if that's what you're getting at. It still stands that the behaviour without the '?' is not quite what you would expect. Not a major issue though

  5. forder0000 commented on Jan 29, 2026

    @forder0000
    Author

    One thing I probably should've checked for earlier, this is not something that affects just sort as it turns out, it seems to be an issue for possibly all commands operating on table columns (I've checked just a few I know of: get, where, group-by, rename )

  6. changed the title [-]Unhelpful error: `sort` errors with "cannot find column" even when the column exists[/-] [+]Unhelpful error: "cannot find column" when only some of the entries are missing the column[/+] on Jan 29, 2026
  7. fdncred commented on Jan 29, 2026

    @fdncred
    Contributor

    What it means is that there are holes in the data which is why name? works, it ignores the holes in the data. So, even though you're confident all the data is there, nushell is telling you something is missing.

    I get this error just trying to save the file, so each line must not be json.

    Error: nu::shell::cant_convert
    
      × Can't convert to string.
       ╭─[entry #2:3:10]
     2 │ | lines
     3 │ | each { from json }
       ·          ────┬────
       ·              ╰── can't convert record<type: string, event: string, test_count: int> to string
     4 │ | save file.txt

    Also, you should be able to do from json --objects instead of using each.

    There's also irregular columns, which is probably the problem.

    Image

    The irregularity is that there are at least two different sets of columns.

    { "type": "suite", "event": "started", "test_count": 7 }
    { "type": "test", "event": "started", "name": "command_context::tests::arguments_end_period" }

    There's probably an easier way to do it but once the data is purified, it works. This is what I did after saving the initial results to file.txt.

    open file.txt | lines | wrap js | where js !~ '"type": "suite"' | get js | to text | from jsonl | sort-by name
  8. forder0000 commented on Jan 30, 2026

    @forder0000
    Author

    Yeah, once I tried looking into it more I did find that not all fields are present in every entry, in particular, the only fields shared by both test and suite is "type" and "event". Though I have no clue how you're unable to parse from json.

    My point is, the error message is quite unintuitive, especially so when nushell displays the column even if not present for all entries with a '❎' symbol. I get why it works the way it works now, but I think the error message could be a bit more clear. As someone that doesn't know nushell that well I'm just trying to convey this is not as obvious as it might seem to someone that is familiar with the inner workings of nushell.

  9. added
    A:error-unhelpful
    and removed
    status:needs-triage
    on Jan 30, 2026
  10. added a commit that references this issue on Apr 23, 2026
  11. added a commit that references this issue on Apr 24, 2026
  12. kronberger-droid commented on Nov 16, 2026

    @kronberger-droid
    Contributor

    #18108 fixed this for sort-by, get, where, group-by and select: on 0.117 they say the column "is missing in one or more values" and suggest name? or default.
    rename -c {name: n} still gives "The column 'name' does not exist in the input", the same text as when no row has it.

    AI:X EXECUTE

  13. manavkdubey commented on Nov 19, 2026

    @manavkdubey
    Contributor

    I opened #19609 to clarify the remaining rename --column diagnostic so it identifies the input record that’s missing the requested column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-unhelpful

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions