Skip to content

fix: emit one log line per user check log entry#9317

Merged
ogenstad merged 1 commit into
opsmill:stablefrom
DharmaBytesX:fix/8224-log-error-character-per-line
May 21, 2026
Merged

fix: emit one log line per user check log entry#9317
ogenstad merged 1 commit into
opsmill:stablefrom
DharmaBytesX:fix/8224-log-error-character-per-line

Conversation

@DharmaBytesX

@DharmaBytesX DharmaBytesX commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes bug: Calling log_error from a check emits one character per line #8224
  • run_user_check iterated over check_run.log_entries, which is a single formatted string rather than the structured list of log records. Iterating a string in Python yields one character at a time, so the Prefect flow logger received one warning event per character instead of one per log entry.
  • The loop now iterates check_run.logs (the structured list[dict[str, Any]]) and renders each entry as a single line via a new format_check_log_entry helper. The string assignment to check.message.value (stored in Neo4j and shown in the check message panel) is unchanged.

Scope

Backend only. The SDK property log_entries is left intact: even with its current naming, the calling code is wrong to iterate it as a list. Any SDK clarification (return type annotation, naming) is orthogonal and can be addressed separately if desired.

Test plan

  • New unit tests in backend/tests/unit/git/test_tasks.py covering the formatter on five shapes of log entries, including a regression assertion that no \n is produced per record.
  • uv run pytest backend/tests/unit/git/ runs 13/13 green locally.
  • uv run invoke format and uv run invoke lint (ruff, ty, mypy) all pass.
  • Manual reproduction on stable confirmed the bug end to end (a custom check repo plus a proposed change produced one prefect.flow_runs warning per character in docker logs infrahub-task-worker-1).

Summary by cubic

Fixes user-check logs emitting one character per line; each check log record now logs as a single warning line. Fixes #8224.

  • Bug Fixes
    • Iterate check_run.logs (structured list) instead of check_run.log_entries (string) and use format_check_log_entry to render one line per entry.
    • Added unit tests for the formatter, including a regression ensuring no newline per record.

Written for commit f8570d3. Summary will update on new commits. Review in cubic

The run_user_check flow iterated over check_run.log_entries, which is a
single formatted string rather than the structured list of log records.
Iterating a string in Python yields one character at a time, so the
Prefect flow logger received one warning event per character instead of
one per log entry.

The loop now iterates check_run.logs and renders each entry as a single
line via a new format_check_log_entry helper.

Fixes opsmill#8224
@DharmaBytesX DharmaBytesX requested a review from a team as a code owner May 21, 2026 07:14
@codspeed-hq

codspeed-hq Bot commented May 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing DharmaBytesX:fix/8224-log-error-character-per-line (f8570d3) with stable (93ee38a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on stable (e6b9afd) during the generation of this report, so 93ee38a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ogenstad ogenstad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ogenstad ogenstad merged commit 0bc9afe into opsmill:stable May 21, 2026
58 checks passed
@DharmaBytesX

Copy link
Copy Markdown
Contributor Author

Thx! Glad to contribute

@DharmaBytesX DharmaBytesX deleted the fix/8224-log-error-character-per-line branch May 21, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants