apt update crashes with "KeyError: 'suite'" in cnf-update-db if index compression is enabled

Bug #1876034 reported by Michael Sparmann on 2020-04-30
This bug affects 10 people
Affects Status Importance Assigned to Milestone
command-not-found (Ubuntu)

Bug Description

On all Ubuntu releases since at least 19.10, enabling compressed APT package list storage with command-not-found installed leads to this crash in the cnf-update-db hook called by apt update:

Traceback (most recent call last):
  File "/usr/lib/cnf-update-db", line 26, in <module>
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 93, in create
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 127, in _fill_commands
    self._parse_single_commands_file(con, fp)
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 165, in _parse_single_commands_file
KeyError: 'suite'

(To enable compressed APT list storage, add Acquire::GzipIndexes "true"; to an apt.conf fragment.)

This appears to be caused by apt downloading an lz4-compressed command list for command-not-found and cnf-update-db passing the /var/lib/apt/lists/*Commands-*.lz4 files to db/creator.py, which does not know about the compression and attempts to parse them as plain text.

Related branches

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in command-not-found (Ubuntu):
status: New → Confirmed
Mathew Hodson (mhodson) on 2020-05-02
Changed in command-not-found (Ubuntu):
importance: Undecided → Medium
sparky3387 (sparky3387) wrote :

As a temporary workaround, you can add to an apt.conf file:
Acquire::GzipIndexes "false";

And do a check to ensure no files have GzipIndexes:
grep -r GzipIndexes /etc/apt

And then delete apt list cache
rm -rf /var/lib/apt/lists

And then finally update
apt-get update

Michael Sparmann (theseven) wrote :

I'm aware of that, but that workaround defeats the point of enabling compressed list storage.
We're using the patch linked above to solve the real issue without that space overhead, but such local fixes are a maintenance issue. Sadly there appears to be no intention to accept the fix upstream.

Michael Sparmann (theseven) wrote :

Actually, upon a closer look, it appears like command-not-found has been entirely unmaintained for more than 2 years now, so efforts to get this fixed upstream, let alone backported to focal, are probably futile.
We should probably just remove this package from our base image and let the end user install some fixed fork of it from a PPA, if they need it. Luckily there's no hard dependency to it from ubuntu-standard.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers