Bug 466318 - fwupd backend errors on startup with fwupd 1.8.11: "user agent unset"
Summary: fwupd backend errors on startup with fwupd 1.8.11: "user agent unset"
Alias: None
Product: Discover
Classification: Applications
Component: fwupd Backend (show other bugs)
Version: 5.27.1
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: Plasma Bugs List
Depends on:
Reported: 2023-02-23 19:20 UTC by Adam Williamson
Modified: 2023-02-24 20:53 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.2


Note You need to log in before you can comment on or make changes to this bug.
Description Adam Williamson 2023-02-23 19:20:51 UTC

With fwupd 1.8.11 (recently released), Discover with the fwupd backend shows an error on startup: "user agent unset". I don't know yet whether this prevents use of Discover entirely (it was caught by an automated test system which isn't smart enough to try closing the dialog and continuing), but I'm pretty sure it at least will render the fwupd backend non-functional.

1. Run Discover with the fwupd backend enabled and fwupd 1.8.11 installed (e.g. on current Fedora Rawhide)

Error is shown.

No error.

Plasma 5.27.1 on Fedora Rawhide (39).

I've root caused this (I think) in the downstream bug: https://bugzilla.redhat.com/show_bug.cgi?id=2173022 . The change that triggered this is a check in `fwupd_client_set_user_agent_for_package` that was added in fwupd 1.8.11: it now bails out if priv->daemon_version is not set. See https://github.com/fwupd/fwupd/commit/34743ff6f48510839ca3ef5f4ad6fe51ffd3425c . This check was added for a good reason: priv->daemon_version is used in constructing the user agent string, so if it's not set, you get "NULL" in the second part of the string, which is bad and apparently confused LVFS.

Discover calls `fwupd_client_set_user_agent_for_package` as just about the first thing it does after creating the client instance. This apparently is too early, nothing has set the daemon version yet. gnome-software, as best as I can tell, waits until it has done `fwupd_client_connect_async` and `fwupd_client_set_feature_flags_async` (and the corresponding `finish` calls) before it does `fwupd_client_set_user_agent_for_package`, with an explicit comment that "/* we know the runtime daemon version now */". So it's intentionally doing the user agent after those two other things with the intent that one of them causes the daemon version to be set. See https://gitlab.gnome.org/GNOME/gnome-software/-/blob/main/plugins/fwupd/gs-plugin-fwupd.c#L285-286 and the blocks around there.

Logically speaking, I guess this means Discover should do something similar: do client_connect and/or set_feature_flags before it does set_user_agent_for_package. I'm trying to write a patch to do that, but I am no kind of C coder so I may fail miserably, so I figured I'd file a bug so better C coders can look at it. :D
Comment 1 Adam Williamson 2023-02-23 20:07:03 UTC
https://invent.kde.org/plasma/discover/-/merge_requests/486 seems to fix it.
Comment 2 Nate Graham 2023-02-24 20:53:47 UTC
Cool, thanks for that!