Skip to content

feat(error make)!: raise errors for invalid labels - #18755

Merged
Bahex merged 5 commits into
nushell:mainfrom
Bahex:push-yrxsxwpypolo
Jul 29, 2026
Merged

Bahex merged 5 commits into
nushell:mainfrom
Bahex:push-yrxsxwpypolo

Conversation

@Bahex

@Bahex Bahex commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Description

Not providing spans for error labels fell back to using the error label record's own span instead. This lead to confusing outcomes, especially because the error label's structure changed at some point:

from record<text: string, start: int, end: int>
to record<text: string, span: record<start: int, end: int>>

User-facing changes (Release notes)

Errors for... error make?

Not specifying the span for error labels (or not doing so correctly) confusingly fell back to using the record's own span instead:

let var = 2
let span = (metadata $var).span

error make {
	msg: "my error"
	label: { text: "two" }
}
Error: nu::shell::error

  × my error
   ╭─[repl_entry #1:6:9]
 5 │     msg: "my error"
 6 │     label: {text: "two"}
   ·            ──────┬──────
   ·                  ╰── two
 7 │ }
   ╰────
let var = 2
let span = (metadata $var).span

error make {
	msg: "my error"
	label: { text: "two", start: $span.start, end: $span.end }
}
Error: nu::shell::error

  × my error
   ╭─[repl_entry #2:6:9]
 5 │     msg: "my error"
 6 │     label: { text: "two", start: $span.start, end: $span.end }
   ·            ─────────────────────────┬─────────────────────────
   ·                                     ╰── two
 7 │ }
   ╰────

So error make succeeded instead of throwing an error. Well, it did throw an error, the one user was trying to, not the one it should due to error make receiving an invalid argument.

From now on error make will raise an error of its own when receiving an invalid argument.

let var = 2
let span = (metadata $var).span

error make {
	msg: "my error"
	label: { text: "two" }
}
Error: nu::shell::missing_required_columns

  × Value is missing required columns.
   ╭─[repl_entry #1:6:9]
 4 │ error make {
 5 │     msg: "my error"
 6 │     label: { text: "two" }
   ·            ───────┬───────
   ·                   ╰── missing `span: record<start: int, end: int>` column
 7 │ }
   ╰────
let var = 2
let span = (metadata $var).span

error make {
	msg: "my error"
	label: { text: "two", start: $span.start, end: $span.end }
}
Error: nu::shell::missing_required_columns

  × Value is missing required columns.
   ╭─[repl_entry #2:6:9]
 4 │ error make {
 5 │     msg: "my error"
 6 │     label: { text: "two", start: $span.start, end: $span.end }
   ·            ─────────────────────────┬─────────────────────────
   ·                                     ╰── missing `span: record<start: int, end: int>` column
 7 │ }
   ╰────

@Bahex
Bahex force-pushed the push-yrxsxwpypolo branch from 92d2374 to e1200b4 Compare July 28, 2026 20:25
@Bahex Bahex added the notes:fixes Noted in "Bug fixes" section label Jul 29, 2026
@Bahex
Bahex merged commit cc7f044 into nushell:main Jul 29, 2026
15 checks passed
@github-actions github-actions Bot added this to the v0.115.0 milestone Jul 29, 2026
@Bahex Bahex added the notes:ready Indicates Ready for Release notes label Aug 11, 2026
KaiSforza added a commit to KaiSforza/nushell that referenced this pull request Sep 16, 2026
## Description
The recent changes in nushell#18755 made it so that errors defined with a simple
`label: {span: ...}` but no `text` value will cause an error (not the one
the user is expecting), when a blank `text` field for a label can be used
to simply underline the span. This will still cause an error if `span` is
not defined for each label, though.

- Reverts the change in nushell#18755 that removed the default `text: ""` value
  to simply underline labels that only have a span.
- Maintains the requirement for a `span` in each label

## User-facing changes (Release notes)
- Adds a default value to `error make`'s labels `text`

## Additional notes
- Reverts parts of nushell#18755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Span issue of $in and $it inside a block

1 participant