Skip to content

Log messages with bare bytes() data structures need an encoding or will fail when throwing an error #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kentbull opened this issue Apr 22, 2025 · 1 comment
Assignees
Labels
bug Something isn't working triage

Comments

@kentbull
Copy link
Contributor

Version

1.1.32, 1.2.6, main

Environment

All

Expected behavior

Log messages like the one made below should not throw encoding errors:

class Kevery:
    ...
    def processEscrowPartialDels(self):
        ...
                dgkey = dgKey(epre, edig)
                if not (esr := self.db.esrs.get(keys=dgkey)):  # get event source, otherwise error
                    # no local source so raise ValidationError which unescrows below
                    msg = f"PDE Missing escrowed event source at dig = {bytes(edig)}"
                    logger.info("Kevery unescrow error: %s", msg)
                    raise ValidationError(msg)

Actual behavior

Many of my recent log messages introduced with the logging overhauls have a bare bytes(...) data structure in them and as such are causing the wrong errors to be thrown during escrow object validation, and likely other places.

All places such log messages are created in 1.1.32, 1.2.6, and main need to be fixed.

For example, the following error needs to be resolved:

2025-04-22 21:22:48 [sally] ERROR    Kevery PDE unescrowed: string argument without an encoding
Traceback (most recent call last):
  File "/keripy/src/keri/core/eventing.py", line 5941, in processEscrowPartialDels
    msg = f"PDE Stale event escrow at dig = {bytes(edig)}"
                                             ^^^^^^^^^^^
TypeError: string argument without an encoding

By specifying an encoding like below:

    msg = f"PDE Stale event escrow at dig = {bytes(edig).encode('utf-8')}"

Steps to reproduce

Send a credential presentation to Sally that does not have a delegation fully complete and this error will be triggered.

@kentbull
Copy link
Contributor Author

Resolved by #976

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant