Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong hint message in into record call #11632

Closed
h4-h opened this issue Jan 24, 2024 · 6 comments · Fixed by #11668
Closed

Wrong hint message in into record call #11632

h4-h opened this issue Jan 24, 2024 · 6 comments · Fixed by #11668
Labels
needs-triage An issue that hasn't had any proper look
Milestone

Comments

@h4-h
Copy link

h4-h commented Jan 24, 2024

Describe the bug

When the script returns a record it converts the return type to a string (idk if this is expected behavior) so if I pipe it in into record (I know it shouldn't work) it will throw an error message input type: string with hint only string input data is supported, but if I pipe string in into record it will give different error command doesn't support string input.

How to reproduce

  1. create script with main function
def main [] {
  return {
    first: "a",
    second: "b",
  };
}
  1. pipe output in into record
    test-bug.nu | into record
  2. get wrong hint

Expected behavior

I think it should print command doesn't support string input.

Screenshots

image

Configuration

key value
version 0.87.1
branch
commit_hash
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.72.1 (d5c2e9c34 2023-09-13)
rust_channel 1.72.1-x86_64-pc-windows-msvc
cargo_version cargo 1.72.1 (103a7ff2e 2023-08-15)
build_time 2023-11-23 12:36:00 -08:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

Additional context

I also have a question about returning a record from a function in a script, why is it a string?

@h4-h h4-h added the needs-triage An issue that hasn't had any proper look label Jan 24, 2024
@h4-h
Copy link
Author

h4-h commented Jan 24, 2024

upd: I updated nushell to the lattest 0.89.0 version and it still happening

@fdncred
Copy link
Collaborator

fdncred commented Jan 25, 2024

How would 'test string' be converted to a record, there is no key/value?

With your script, when you do nu test-bug.nu | into record that shouldn't work either because you're shelling out to a new instance of nu, running a script that returns a record but the the output is converted to a string and then you try to convert a string into a record which isn't supported.

@h4-h
Copy link
Author

h4-h commented Jan 25, 2024

How would 'test string' be converted to a record, there is no key/value?

I'm not saying it should work with strings, i'm saying the hint message is wrong, it shouldn't be a only string input data is supported because if I pass a string it throw command doesn't support string input.

@fdncred
Copy link
Collaborator

fdncred commented Jan 25, 2024

oh, i see what you're saying. i wonder why it says that? maybe it means that nu test-bug.nu only outputs strings?

@KAAtheWiseGit
Copy link
Contributor

nu test-bug.nu outputs raw input as per describe.

Looking at the code, it simply uses string message for all unsupported types:

        Value::Record { val, .. } => Value::record(val, span),
        Value::Error { .. } => input,
        other => Value::error(
            ShellError::OnlySupportsThisInputType {
                exp_input_type: "string".into(),
                wrong_type: other.get_type().to_string(),
                dst_span: call.head,
                src_span: other.span(),
            },
            call.head,
        ),

The error must've been refactored at some point.

I'll replace it with a TypeMismatch error and send a PR.

@KAAtheWiseGit
Copy link
Contributor

While I was making the PR I realized the problem was a different one. The command was never supposed to let raw input type in, it should've thrown an error earlier. Signature guards didn't work for some reason

KAAtheWiseGit added a commit to KAAtheWiseGit/nushell that referenced this issue Jan 29, 2024
@hustcer hustcer added this to the v0.90.0 milestone Jan 30, 2024
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this issue Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants