#1043578 apt update gives weird errors when apt/lists files are truncated to 0 bytes

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Russell Coker
Date:
2023-08-13 08:27:06 UTC
Severity:
normal
#1043578#5
Date:
2023-08-13 08:23:00 UTC
From:
To:
echo -n > /var/lib/apt/lists/www.coker.com.au_dists_bookworm_InRelease
echo -n > /var/lib/apt/lists/www.coker.com.au_dists_bookworm_misc_binary-arm64_Packages

I ran the above commands to truncate the apt lists files for my source and
ran "apt update" and got the below error.

What I expected to happen is to have apt say "cached files are corrupt,
refreshing from the net" or something similar.  While it is technically
correct to say that the files couldn't be split into parts, the correct
thing to say is "no data found".

The reason I tested this is that I had a problem on an Ubuntu system with
zero byte files in /var/lib/apt/lists (for unknown reasons) and chose
Debian/Unstable as the platform to reproduce and report the bug.

# apt update
Hit:1 http://deb.debian.org/debian unstable InRelease
Hit:2 http://repo.mobian.org trixie InRelease
Hit:3 https://www.coker.com.au bookworm InRelease
Err:3 https://www.coker.com.au bookworm InRelease
  Splitting up /var/lib/apt/lists/www.coker.com.au_dists_bookworm_InRelease into data and signature failed
Reading package lists... Error!
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://www.coker.com.au bookworm InRelease: Splitting up /var/lib/apt/lists/www.coker.com.au_dists_bookworm_InRelease into data and signature failed
W: Failed to fetch https://www.coker.com.au/dists/bookworm/InRelease  Splitting up /var/lib/apt/lists/www.coker.com.au_dists_bookworm_InRelease into data and signature failed
W: Some index files failed to download. They have been ignored, or old ones used instead.
E: Splitting of clearsigned file /var/lib/apt/lists/www.coker.com.au_dists_bookworm_InRelease failed as it doesn't contain all expected parts
E: The package lists or status file could not be parsed or opened.