lubuntu-notifier.py crashes with a type mismatch error when packages are to be removed

Bug #2012823 reported by Aaron Rainbolt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lubuntu-update-notifier (Ubuntu)
Fix Released
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned
Kinetic
Fix Released
Undecided
Unassigned
Lunar
Fix Released
Undecided
Unassigned

Bug Description

[ Impact ]

In lubuntu-update-notifier, the lubuntu-notifier.py script displays a pop-up that allows the user to install system updates if they are available. This pop-up works just fine as long as the only changes to be made are packages being installed or updated, but thanks to a coding error, it fails to pop up if any packages are to be removed. This means that, if an update is going to remove packages, it won't be displayed to the user. This will make it so that the user is no longer notified to update their system until the package that needs removed is removed, requiring manual user intervention. In the worst case, a user who doesn't know how to use the terminal and doesn't realize that the lack of update prompts is a bad thing may end up with their system not updating (except for updates that unattended-upgrades installs in the background).

This SRU fixes the bug by fixing the coding error. Part of the UI code is supposed to pass an Iterable[str] to a particular function when a package is to be removed. Unfortunately, a plain string is being passed to this function instead, and the function does not accept plain strings. The entire fix involves adding two brackets to one line to change the string to a string array.

[ Test plan ]

Ubuntu Jammy and Ubuntu Kinetic do not (yet) have an update for Lubuntu that requires a package to be removed, so this bug is not easy to reproduce (as far as I know) on Jammy or Kinetic. However, inspecting the code should be sufficient. Additionally this bug actually happened in Lunar and this fix worked.

1. Download the lubuntu-update-notifier source package from jammy-proposed or kinetic-proposed.
2. Open the lubuntu-notifier.py file.
3. Search for QTreeWidgetItem in the file, and verify that when it is used, it has string arrays being passed to it rather than plain strings.
4. Look at the debdiff and ensure that the only change made from the last version is that "QTreeWidgetItem(p.name)" has been changed to "QTreeWidgetItem([p.name])".

[ Where problems could occur ]

If QTreeWidgetItem somehow doesn't take a string array despite my testing in Lunar, then things will probably go awry when an update comes through that has to remove packages. But string arrays are already being passed to QTreeWidgetItem elsewhere in the code, and in Lunar where this bug is reproducible, this fix worked, so I find it very unlikely that this will go wrong.

---

Original bug report:

Steps to reproduce:

1. Boot a Lubuntu Lunar ISO dated 20230325.
2. Run "sudo apt update".
3. Run "/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py -p /usr/bin/lubuntu-upgrader -u 1 -s 0".

Expected result: A window should appear asking if you want to do a system upgrade. Some packages will be listed as to-be-removed.

Actual result: lubuntu-notifier.py crashes and prints out a stacktrace.

Additional info:

The stacktrace:

-----

lubuntu@lubuntu:~$ /usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py -p /usr/bin/lubuntu-upgrader -u 1 -s 0
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Traceback (most recent call last):
  File "/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py", line 266, in <module>
    main(sys.argv, int(options.upgrades), int(options.security_upgrades),
  File "/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py", line 231, in main
    app = App(upgrades, security_upgrades, reboot_required, upg_path, args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py", line 223, in __init__
    self.dialog = Dialog(upgrades, security_upgrades, reboot_required,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py", line 59, in __init__
    self.initUI()
  File "/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py", line 132, in initUI
    td_child = QTreeWidgetItem(p.name)
               ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: arguments did not match any overloaded call:
  QTreeWidgetItem(type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(strings: Iterable[str], type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(parent: QTreeWidget, type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(parent: QTreeWidget, strings: Iterable[str], type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(parent: QTreeWidget, preceding: QTreeWidgetItem, type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(parent: QTreeWidgetItem, type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(parent: QTreeWidgetItem, strings: Iterable[str], type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(parent: QTreeWidgetItem, preceding: QTreeWidgetItem, type: int = QTreeWidgetItem.Type): argument 1 has unexpected type 'str'
  QTreeWidgetItem(other: QTreeWidgetItem): argument 1 has unexpected type 'str'

-----

In more readable terms, p.name is a string, while QTreeWidgetItem expects an Iterable[str]. Changing "p.name" to "[p.name]" in the line fixes this in my testing.

description: updated
description: updated
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lubuntu-update-notifier - 0.5.4

---------------
lubuntu-update-notifier (0.5.4) lunar; urgency=medium

  * Disconnect the status_changed() function from the status-changed signal in
    repair_install(), as it interferes with upgrade_progress_download().
    (LP: #2012702)
  * Don't try to pass a string to QTreeWidgetItem when it expects an
    Iterable[str]. (LP: #2012823)

 -- Aaron Rainbolt <email address hidden> Sun, 26 Mar 2023 10:48:15 -0500

Changed in lubuntu-update-notifier (Ubuntu Lunar):
status: New → Fix Released
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Aaron, or anyone else affected,

Accepted lubuntu-update-notifier into kinetic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/lubuntu-update-notifier/0.5.1~22.10.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-kinetic to verification-done-kinetic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-kinetic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in lubuntu-update-notifier (Ubuntu Kinetic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-kinetic
Revision history for this message
Timo Aaltonen (tjaalton) wrote :

Hello Aaron, or anyone else affected,

Accepted lubuntu-update-notifier into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/lubuntu-update-notifier/0.5.1~22.04.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in lubuntu-update-notifier (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed-jammy
Revision history for this message
Aaron Rainbolt (arraybolt3) wrote :

Both uploads have been double-checked as described in the test case and look OK to me.

tags: added: verification-done verification-done-jammy verification-done-kinetic
removed: verification-needed verification-needed-jammy verification-needed-kinetic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lubuntu-update-notifier - 0.5.1~22.04.3

---------------
lubuntu-update-notifier (0.5.1~22.04.3) jammy; urgency=medium

  * Don't try to pass a string to QTreeWidgetItem when it expects an
    Iterable[str]. (LP: #2012823)

 -- Aaron Rainbolt <email address hidden> Sun, 26 Mar 2023 12:21:33 -0500

Changed in lubuntu-update-notifier (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for lubuntu-update-notifier has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lubuntu-update-notifier - 0.5.1~22.10.3

---------------
lubuntu-update-notifier (0.5.1~22.10.3) kinetic; urgency=medium

  * Don't try to pass a string to QTreeWidgetItem when it expects an
    Iterable[str]. (LP: #2012823)

 -- Aaron Rainbolt <email address hidden> Sun, 26 Mar 2023 16:29:40 -0500

Changed in lubuntu-update-notifier (Ubuntu Kinetic):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.