Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use errors.Is() for invalid argument #483

Merged
merged 1 commit into from Dec 22, 2022
Merged

Use errors.Is() for invalid argument #483

merged 1 commit into from Dec 22, 2022

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Dec 22, 2022

Switch to using Go errors.Is() to check for the "invalid argument" error.

Signed-off-by: SuperQ superq@gmail.com

Switch to using Go errors.Is() to check for the "invalid argument"
error.

Signed-off-by: SuperQ <superq@gmail.com>
Copy link
Member

@discordianfish discordianfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SuperQ SuperQ merged commit bb7727a into master Dec 22, 2022
@SuperQ SuperQ deleted the superq/err_invalid branch December 22, 2022 13:34
@dcbw
Copy link
Contributor

dcbw commented May 10, 2023

@SuperQ @discordianfish turns out this PR now prematurely terminates parsing on at least some systems (RHEL, Fedora) because the "invalid argument" error is actually a syscall.Errno EINVAL because SysReadFile() uses syscall.Read() instead of os.ReadFile() or os.Read().

Should I do a patch with a function that checks errors.Is(err, syscall.Errno) and compares to EINVAL, or should we revert?

dcbw added a commit to dcbw/procfs that referenced this pull request May 10, 2023
prometheus#483 introduced a bug
that terminates attribute reading when the returned error is
syscall.Errno, which is what util.SysReadFile() will typically
return. Handle that case specifically.

While doing that pull the error checking into
ParseNetClassAttribute() for clarity and to allow external
callers to handle errors correctly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
dcbw added a commit to dcbw/procfs that referenced this pull request May 10, 2023
prometheus#483 introduced a bug
that terminates attribute reading when the returned error is
syscall.Errno, which is what util.SysReadFile() will typically
return. Handle that case specifically.

While doing that pull the error checking into
ParseNetClassAttribute() for clarity and to allow external
callers to handle errors correctly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
dcbw added a commit to dcbw/procfs that referenced this pull request May 10, 2023
prometheus#483 introduced a bug
that terminates attribute reading when the returned error is
syscall.Errno, which is what util.SysReadFile() will typically
return. Handle that case specifically.

While doing that pull the error checking into
ParseNetClassAttribute() for clarity and to allow external
callers to handle errors correctly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
dcbw added a commit to dcbw/procfs that referenced this pull request May 15, 2023
prometheus#483 introduced a bug
that terminates attribute reading when the returned error is
syscall.Errno, which is what util.SysReadFile() will typically
return. Handle that case specifically.

While doing that pull the error checking into
ParseNetClassAttribute() for clarity and to allow external
callers to handle errors correctly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
discordianfish pushed a commit that referenced this pull request May 17, 2023
#483 introduced a bug
that terminates attribute reading when the returned error is
syscall.Errno, which is what util.SysReadFile() will typically
return. Handle that case specifically.

While doing that pull the error checking into
ParseNetClassAttribute() for clarity and to allow external
callers to handle errors correctly.

Signed-off-by: Dan Williams <dcbw@redhat.com>
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.

None yet

3 participants