Repository navigation
fix: change errorf format to represent real value - #368
Merged
Merged
Conversation
Spuxy
requested review from
floryut,
rkmathi,
superbrothers and
tksm
as code owners
May 2, 2026 20:36
tksm
approved these changes
May 3, 2026
tksm
left a comment
Contributor
There was a problem hiding this comment.
LGTM 👍. Verified against the released stern (without fix) and a dist/stern built from this branch (with fix).
make build # produces dist/stern from this branch
for bin in stern ./dist/stern; do
echo "### $bin ($("$bin" --version | head -1))"
for cfg in 'since: 60' 'since: true' $'tail:\n - 1\n - 2'; do
printf '%s\n' "$cfg" > /tmp/cfg.yaml
echo "--- $cfg"
"$bin" --config /tmp/cfg.yaml foo 2>&1 | head -1
done
echo
done### stern (version: 1.34.0)
--- since: 60
Error: invalid value '<' for "since" in the config file: time: missing unit in duration "60"
--- since: true
Error: invalid value %!q(bool=true) for "since" in the config file: time: invalid duration "true"
--- tail:
- 1
- 2
Error: invalid value ['\x01' '\x02'] for "tail" in the config file: strconv.ParseInt: parsing "[1 2]": invalid syntax
### ./dist/stern (version: dev)
--- since: 60
Error: invalid value 60 for "since" in the config file: time: missing unit in duration "60"
--- since: true
Error: invalid value true for "since" in the config file: time: invalid duration "true"
--- tail:
- 1
- 2
Error: invalid value [1 2] for "tail" in the config file: strconv.ParseInt: parsing "[1 2]": invalid syntax
@Spuxy Thanks for the fix!
Could you please rebase this PR? Once that's done, I'll merge it.
Contributor
Author
|
Yep ill do |
Spuxy
force-pushed
the
fix-config-error-format
branch
from
May 3, 2026 07:33
04249b3 to
e2417d6
Compare
Contributor
|
Thank you for the PR! |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cmd/cmd.go:443
and
cmd/cmd.go:450
both use
fmt.Errorf("invalid value %q for %q in the config file: %v", value, name, err).The first
%qformats value, which isinterface{}from a YAML decode (could be slice, int, bool, etc.), so%qis wrong.I have changed that first
%qto%von both lines.Testing yaml file: