After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697819 - gdbus-codegen: Automatically strip remote errors in generated code
gdbus-codegen: Automatically strip remote errors in generated code
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gdbus
2.36.x
Other Linux
: Normal minor
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-04-11 16:19 UTC by Matthew Barnes
Modified: 2018-05-24 15:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Matthew Barnes 2013-04-11 16:19:04 UTC
Maybe I'm missing the use case for keeping the extra GDBus gunk around in GError messages, but I would think at least code generated by the gdbus-codegen tool would strip that stuff out automatically.

Currently, apps have to remember to call g_dbus_error_strip_remote_error() at pretty much any place where a GError message is displayed, lest users see messages like:

GDBus.Error:org.gnome.OnlineAccounts.Error.NotAuthorized: No credentials found in the keyring

I can maybe see keeping the remote error info around when using the GDBus APIs directly, but surely apps shouldn't have to deal with that in generated convenience APIs, no?
Comment 1 David Zeuthen (not reading bugmail) 2013-04-11 16:52:30 UTC
There's really no guarantee that the you have associated a GError domain with the returned error and that's why we don't - and cannot - just do what you suggest. For example, you could be communicating with a newer version of your own code or it could be a reimplementation. Things like that.

That said, I agree it's annoying having to do this and think it would be fine to add a --c-strip-errors command-line option that you can use if you have certain guarantees about the other end...
Comment 2 Matthew Barnes 2013-04-11 17:11:01 UTC
I'm not really familiar with how this works internally, but could it at least try to strip it automatically and leave it as is if it can't find a matching error domain?  Again, just for generated code.  I'm fine with no guarantees.
Comment 3 Matthew Barnes 2013-04-12 12:47:53 UTC
To clarify: I'd be happy with a --c-strip-errors option as well.

Didn't mean for that last comment to sound so whiny, it was meant as a suggestion only.  :)
Comment 4 David Zeuthen (not reading bugmail) 2013-04-12 18:31:02 UTC
(In reply to comment #2)
> I'm not really familiar with how this works internally, but could it at least
> try to strip it automatically and leave it as is if it can't find a matching
> error domain?  Again, just for generated code.  I'm fine with no guarantees.

No, there's unfortunately no way to do this automatically because even if the D-Bus error is mapped to something that isn't (G_IO_ERROR, G_IO_ERROR_DBUS_ERROR), we _still_ want to preserve information that it _is_ a remote error. And the way this is done - g_dbus_error_is_remote_error() is (drumroll)

 https://git.gnome.org/browse/glib/tree/gio/gdbuserror.c?id=2.36.0#n473

The root problem, really, is that GError is not extensible. So we have to play games like this.

Concrete example. The remote process is using g_dbus_method_invocation_return_gerror() to return a (G_IO_ERROR, G_IO_ERROR_NOT_FOUND) GError. Your process receives the D-Bus error (just a name + message) and uses the extra information to infer that it's (G_IO_ERROR, G_IO_ERROR_NOT_FOUND). But we _do not_ delete the extra information because otherwise g_dbus_error_is_remote_error() will not work.

So I think the only viable option is adding a --c-strip-errors option.
Comment 5 Matthew Barnes 2013-04-12 18:39:45 UTC
Fair enough.  I think for my purpose I would never care if it's a remote error or not, but I can understand not wanting to break that.
Comment 6 GNOME Infrastructure Team 2018-05-24 15:10:16 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/689.