Skip to content

feat: point config errors to the line of the invalid entry - #37

Merged
iamralch merged 1 commit into
mainfrom
feat/config-error-lines
Oct 7, 2026
Merged

iamralch merged 1 commit into
mainfrom
feat/config-error-lines

Conversation

@iamralch

@iamralch iamralch commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

A half-deleted secret, e.g. a - kind: env line left without name and path, reported only secret at profile 'p' index 3 missing 'name' field: a 0-based index, no line number, and only the first missing field.

Config errors for profiles and secrets with missing fields now report the line, the secret's name (or its 1-based position), the fields that are there, and every missing field:

secret #4 in profile 'personal' (line 17, kind: env) is missing 'name' and 'path'
secret 'A' in profile 'p' (line 8, kind: env) is missing 'path'
profile #1 (line 3) is missing 'name' and 'provider'
profile 'p' (line 3) is missing 'provider'
  • serde_yaml_ng keeps no positions, but it stamps errors with the position of the mapping they are raised in. So when validation fails, line_of reads the YAML again up to the entry and raises an error there on purpose to get its line. Valid configs are parsed once, as before, and no dependency is added.
  • Missing fields are now checked before an invalid kind or variable name, so an entry with both problems reports the missing fields first.
  • A profile with no name but a leftover zsh-op-style account: key now gets the missing name/provider message. Named profiles still get the hint to move account into the provider.

Tested with unit tests for the messages, a half-deleted entry among valid ones, an empty entry, and line_of on block- and flow-style YAML (all 166 tests pass, clippy clean). Also tried the binary on a broken config.

Closes #35

A half-deleted secret, e.g. a `- kind: env` line left without `name`
and `path`, reported only `secret at profile 'p' index 3 missing 'name'
field`: a 0-based index, no line, and only the first missing field.

Config errors for profiles and secrets missing fields now give the line,
the 1-based position or the name, the fields that are there, and every
missing field:

  secret #4 in profile 'personal' (line 17, kind: env) is missing 'name' and 'path'

serde_yaml_ng keeps no positions, so on such an error the YAML is read
again up to the entry, and an error raised there on purpose carries its
line.

Closes #35
@iamralch iamralch self-assigned this Oct 7, 2026
@iamralch
iamralch merged commit 7e30eb9 into main Oct 7, 2026
8 checks passed
@iamralch
iamralch deleted the feat/config-error-lines branch October 7, 2026 06:41
@ralch ralch Bot mentioned this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Point to the line of an invalid secret in config errors

1 participant