Repository navigation
Add warning to url join when input key is not supported (#10506) - #10565
Conversation
|
Seems like we'd want a ShellError here versus a println! right? Which other warnings are you talking about? |
|
@fdncred I thought this would make more sense as a warning than an error since, if the required fields are present, it will still work, just not include that one field (as in @amtoine's example below). I can change it to an error if you think that would make more sense. > {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
foo://barTo your second question: The only other place I found a warning message was what I linked (below), but I may be missing something. I agree, a simple nushell/crates/nu-glob/src/lib.rs Line 434 in 20aaaaf Thanks |
|
We try to stay away from println!'s and we don't have a ShellWarning, only ShellError. I'm not sure what the right solution is here. @amtoine any ideas? |
|
For the deprecations we use nushell/crates/nu-command/src/random/decimal.rs Lines 45 to 54 in 20aaaaf |
|
Oh interesting... I'll look into that @sholderbach |
|
yup, the |
|
I'm working on adding this new error but I'm having trouble attaching the error message to the col of the input record instead of the value (example below) ➜ {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
Error: × 'im_not_a_url_field' is not a valid URL field
╭─[entry #1:1:1]
1 │ {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
· ──┬─
· ╰── Remove 'im_not_a_url_field' col from input record
╰────
foo://barThe problem I'm having is that the I could also just do this: ➜ {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
Error: × 'im_not_a_url_field' is not a valid URL field
╭─[entry #1:1:1]
1 │ {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
· ───────────────────────────┬──────────────────────────
· ╰── Remove 'im_not_a_url_field' col from input record
╰────
foo://bar |
|
@brunerm99 i could go with either one 👍 |
| .into_iter() | ||
| .try_fold(UrlComponents::new(), |url, (k, v)| { | ||
| url.add_component(k, v, span) | ||
| url.add_component(k, v, span, engine_state) |
There was a problem hiding this comment.
Added engine_state to url.add_component() for report_error_new. I think this should be fine, let me know if not.
|
I went with this: ➜ {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
Error: × 'im_not_a_url_field' is not a valid URL field
╭─[entry #1:1:1]
1 │ {scheme: "foo", host: "bar", im_not_a_url_field: "hi"} | url join
· ───────────────────────────┬──────────────────────────
· ╰── Remove 'im_not_a_url_field' col from input record
╰────
foo://barMakes more sense to me. |
sholderbach
left a comment
There was a problem hiding this comment.
Looks good if the design should be that this is only a warning. Haven't follow the potential debate why this should not lead to a hard error.
But tweaking that at a later date would now be trivial thanks to you figuring out the ShellError with spans for this.
fdncred
left a comment
There was a problem hiding this comment.
I'm not sure if a warning versus and error is appropriate but I'm willing to move forward with this PR since, I think it's better than before with either solution.
) (nushell#10565) <!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close #xxxx - fixes #xxxx you can also mention related issues, PRs or discussions! --> # Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> Adds warning to `url join` when input key is not supported as suggested by @amtoine in nushell#10506. It just adds a `println!` statement but it seems like that is all that is done for other warnings, e.g., https://github.com/nushell/nushell/blob/20aaaaf90c24ea5495cba3396d3977ab10923488/crates/nu-glob/src/lib.rs#L434 # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> All pass.
Description
Adds warning to
url joinwhen input key is not supported as suggested by @amtoine in #10506.It just adds a
println!statement but it seems like that is all that is done for other warnings, e.g.,nushell/crates/nu-glob/src/lib.rs
Line 434 in 20aaaaf
Tests + Formatting
All pass.