Skip to content

bug: Calling log_error from a check emits one character per line #8224

Description

@nrnvgh

Component

Python SDK, Git Integration

Infrahub version

1.7.1 (2413b7c)

Current Behavior

The following code in a check:

    class MyCheck(InfrahubCheck):
        def validate(self, data: dict) -> None:
            [...redacted...]

            message = (
                f"Duplicate serial '{serial}' for manufacturer '{manufacturer_name}'. "
                f"Assets: '{first['tag']}' and '{asset_tag}'."
            )

            self.log_error(message=message, object_id=asset_id, object_type="DcimDeviceAsset")

Results in this (truncated, as it goes for quite a while) log message:

Image

It appears to be caused by InfrahubCheck.log_entries @ https://github.com/opsmill/infrahub-sdk-python/blob/d116aa39c2f739d1fc96af26679bc2e0087b43d9/infrahub_sdk/checks.py#L120-L131

...which returns a string that backend.infrahub.git.tasks:run_user_check then iterates over, emitting one character per line.

Expected Behavior

Emit one log entry per line.

Steps to Reproduce

  1. Create a Check which emits a log entry
  2. Trigger the check; in my testing, I submitted a proposed change (Draft)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working as expected

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions