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

Bug Report: code check call.Err !=nil but return a nil value error err #3012

Open
alingse opened this issue Dec 15, 2024 · 4 comments
Open
Labels
bug Defects

Comments

@alingse
Copy link

alingse commented Dec 15, 2024

Summary

do you mean return call.Err or just return nil to ignore the call.Err ?

Steps To Reproduce

Expected behavior

Environment

  • OS: [e.g. Mac OS X High Sierra, Ubuntu 18.04, Windows 10, ...]
  • OS version: [uname -a]
  • gopass Version: [gopass version]
  • Installation method: [e.g. from source, brew, gopass repo]

Additional context

I create a linter to detect code that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result listed in alingse/sundrylint#4

@dominikschulz dominikschulz added the can-not-reproduce Bug can't be reproduced label Dec 16, 2024
@dominikschulz
Copy link
Member

Please provide more details.

@alingse
Copy link
Author

alingse commented Dec 16, 2024

@dominikschulz

if err != nil {
debug.Log("DBus failure: %s", err)
return err
}
obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
call := obj.Call("org.freedesktop.Notifications.Notify", 0, "gopass", uint32(0), iconURI(ctx), subj, msg, []string{}, map[string]dbus.Variant{"transient": dbus.MakeVariant(true)}, int32(3000))
if call.Err != nil {
debug.Log("DBus notification failure: %s", call.Err)
return err

check if call.Err != nil but just return a already nil value err

@dominikschulz
Copy link
Member

Ha, looks legit, indeed. Thanks.

@dominikschulz dominikschulz reopened this Dec 16, 2024
@dominikschulz dominikschulz added bug Defects and removed can-not-reproduce Bug can't be reproduced labels Dec 17, 2024
@Denis-Kuso
Copy link
Contributor

I’d like to work on fixing this. Seems like just a small correction in the variable return. Will submit a PR soon.

Denis-Kuso added a commit to Denis-Kuso/gopass-fork that referenced this issue Dec 19, 2024
This fixes the issue gopasspw#3012 where the error returned by the `Notify()`
call would incorrectly return a nil value (from `dbus.SessionBus()`),
instead of the correct non-nil value (from `call.Err`).

Signed-off-by: Denis-Kuso <[email protected]>
dominikschulz pushed a commit that referenced this issue Dec 23, 2024
This fixes the issue #3012 where the error returned by the `Notify()`
call would incorrectly return a nil value (from `dbus.SessionBus()`),
instead of the correct non-nil value (from `call.Err`).

Signed-off-by: Denis-Kuso <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects
Projects
None yet
Development

No branches or pull requests

3 participants