Skip to content

fix(cmd): use errors.As instead of a type assertion for viper's not-found error - #60

Merged
sbldevnet merged 2 commits into
mainfrom
agent/go-dev/3c2d8d0e2437
Sep 28, 2026
Merged

sbldevnet merged 2 commits into
mainfrom
agent/go-dev/3c2d8d0e2437

Conversation

@sbldevnet

Copy link
Copy Markdown
Owner

Summary

  • initConfig used a direct type assertion (err.(viper.ConfigFileNotFoundError)) to detect a missing config file, which fails to match if the error is ever wrapped.
  • Replaced it with errors.As, which unwraps the error chain correctly.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (existing "config file not found" tests still pass)

…ound error

A wrapped ConfigFileNotFoundError would not be caught by the direct
type assertion.
@sbldevnet
sbldevnet merged commit 0ccddb9 into main Sep 28, 2026
4 checks passed
@sbldevnet
sbldevnet deleted the agent/go-dev/3c2d8d0e2437 branch September 28, 2026 11:20
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.

1 participant