Skip to content

Backup restore logging drops cog names and raises TypeError for failed libraries #6792

Description

@potatosips

What Red version are you using?

3.5.25.dev1 (V3/develop @ 61484f2)

What were you trying to do?

Restore third-party cogs from a Red backup with redbot-setup restore. I audited the failure reporting in redbot.core._downloader._restore_from_backup() because these messages are the only diagnostic output when a cog cannot be restored.

What did you expect to happen?

Every restore failure should produce a normal log record containing the cog name, repository name, and failed shared-library names. Logging a recovery failure must not itself raise a formatting exception.

What actually happened?

Three log calls in the restore path have missing format arguments.

  • Lines 989 and 994 log The commit that %r cog... without passing cog.name, so the literal placeholder is printed instead of the affected cog.
  • The failed_libs branch at lines 1066-1069 has three placeholders but passes only two arguments. Python logging raises TypeError: not enough arguments for format string, and the intended failure message is lost.

Observed output:

WARNING:The commit that %r cog was installed from is unknown ...
ERROR:The commit that %r cog was installed from is unknown ...
--- Logging error ---
TypeError: not enough arguments for format string
Message: 'Failed to reinstall shared libraries for %r cog from %r repo: %s'
Arguments: ('repo-name', 'lib-name')

How can we reproduce this error?

  1. Check out V3/develop at 61484f28f7fcfff81309cb2b0b0d5287c921f1ad and install the test dependencies on Python 3.11.
  2. Attach a logging.StreamHandler to red.core.downloader.
  3. Exercise the two no-commit branches in _restore_from_backup(); both records retain a literal %r.
  4. Return a CogInstallResult with a non-empty failed_libs tuple from install_cogs().
  5. Observe the logging traceback above instead of the intended cog/repository/library diagnostic.

The same failure can be isolated with the production format string:

log.error(
    'Failed to reinstall shared libraries for %r cog from %r repo: %s',
    'repo-name',
    'lib-name',
)

Anything else?

Environment: Debian Bookworm arm64 container, Python 3.11.15. The unmodified baseline passes 313 passed, 7 skipped; pylint --errors-only redbot independently reports E1206 at line 1066. I searched open and closed issues for the exact messages, backup restore logging errors, failed shared libraries, and missing commit metadata; no duplicate was found.

Likely minimal fix: pass cog.name to both missing-commit messages, and pass cog.name, cog.repo.name, then the joined library names to the failed-libraries message. I will add regression coverage for all three formatted records separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Needs TriageThis has not been labeled or discussed for handling yet.Type: BugUnexpected behavior, result, or exception. In case of PRs, it is a fix for the foregoing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions