'dnf needs-restarting' complains about missing cache despite refreshed beforehand

I have a fairly sophisticated upgrade script, which runs the following in sequence:

dnf --assumeyes --refresh check-update
dnf --assumeyes upgrade --downloadonly
# some arbitrary commands here
dnf --assumeyes --cacheonly upgrade
dnf --cacheonly needs-restarting

All works with the exception of the last command, which complains with the following output (exit code 1):

Updating and loading repositories:
Cache-only enabled but no cache for repository “updates”

The reason I introduced “–cacheonly“ for “needs-restarting“ was that I have a server, which is offline starting from the 3rd command.

With DNF5’s introduction to refresh the repositories despite already being updated recently (same script moments ago) unnecessarily extends the downtime from a mere few minutes to 15-30 minutes extra until all attempted servers timed out repeatedly.

Asking some AI tool I was told to also include dnf --refresh makecache, but running this for tests bare on the command line did not help anything either (same error).

Is this a bug in the “needs-restarting“ plugin/command of DNF5 (e.g. does it somehow not read the refreshed repositories)?

Tried. Worked. Thank you! :slightly_smiling_face:

Can you enlighten me what these options do (differently) or where I can read up on them, please?