Skip to content

fix(logging): preserve critical exception tracebacks - #746

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/log-critical-exceptions
May 3, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/log-critical-exceptions

Conversation

@Sinity

@Sinity Sinity commented May 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds exc_info=True to warning/critical exception log sites that currently log only stringified exceptions.

Problem

Several archive, acquisition, rendering, and query failure paths were preserving the error message but dropping the traceback. That makes post-incident diagnosis harder, especially for the same performance and maintenance work tracked in the daemon/event-history direction.

Solution

Update the affected logger calls in:

  • polylogue/cli/query.py
  • polylogue/operations/archive.py
  • polylogue/pipeline/services/acquisition.py
  • polylogue/pipeline/services/acquisition_persistence.py
  • polylogue/pipeline/services/ingest_batch.py
  • polylogue/pipeline/services/rendering.py

Ref #716

Verification

  • git diff --check HEAD~1..HEAD
  • ruff check polylogue/cli/query.py polylogue/operations/archive.py polylogue/pipeline/services/acquisition.py polylogue/pipeline/services/acquisition_persistence.py polylogue/pipeline/services/ingest_batch.py polylogue/pipeline/services/rendering.py
  • Pre-push hook: devtools verify --quick passed (ruff format, ruff check, mypy, render-all, verify-topology, verify-layering, verify-file-budgets, verify-test-ownership, verify-schema-roundtrip, verify-cross-cuts, verify-suppressions, verify-manifests, verify-witness-lifecycle, proof-pack check)

Summary by CodeRabbit

Chores

  • Improved error logging across core services to capture complete exception stack traces during failures in query processing, data acquisition, persistence, batch operations, and rendering, enabling better diagnostics and troubleshooting.

Add exc_info=True to 5 logger.error/warning calls that were losing
tracebacks. Promote last-sync-timestamp query failure from debug to
warning with exc_info=True.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented May 3, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 158dbb58-84b1-4dd9-a937-6542f99aa090

📥 Commits

Reviewing files that changed from the base of the PR and between 5238997 and 5011686.

📒 Files selected for processing (6)
  • polylogue/cli/query.py
  • polylogue/operations/archive.py
  • polylogue/pipeline/services/acquisition.py
  • polylogue/pipeline/services/acquisition_persistence.py
  • polylogue/pipeline/services/ingest_batch.py
  • polylogue/pipeline/services/rendering.py

📝 Walkthrough

Walkthrough

The PR enhances exception logging across multiple service modules by adding exc_info=True to logger calls, ensuring full stack tracebacks are captured in logs. One change also elevates archive timestamp-lookup failures from debug to warning level.

Changes

Exception Logging Enhancements

Layer / File(s) Summary
Pipeline Service Exception Handlers
polylogue/pipeline/services/acquisition.py, polylogue/pipeline/services/acquisition_persistence.py, polylogue/pipeline/services/ingest_batch.py, polylogue/pipeline/services/rendering.py
Source scan, raw record persistence, session insights refresh, and render failures now log full exception tracebacks via exc_info=True.
Operations & CLI Exception Handlers
polylogue/operations/archive.py, polylogue/cli/query.py
Archive timestamp-lookup failures are promoted from debug to warning level with stack traces; vector search setup failures now log full tracebacks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • Issue #725: The changes directly address logging improvements by adding exc_info=True to exception handlers and adjusting log levels, matching the objectives of this existing issue.

Poem

Hop and log, the traceback shows,
Where each exception flows,
Debug to warning, stack so bright, 🐰
Debugging made clear as night! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/log-critical-exceptions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity marked this pull request as ready for review May 3, 2026 04:11
Copilot AI review requested due to automatic review settings May 3, 2026 04:11
@Sinity
Sinity merged commit 77da802 into master May 3, 2026
3 of 4 checks passed
@Sinity
Sinity deleted the feature/fix/log-critical-exceptions branch May 3, 2026 04:11
@Sinity
Sinity removed the request for review from Copilot May 3, 2026 04:35
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Adds `exc_info=True` to warning/critical exception log sites that currently log only stringified exceptions.

## Problem

Several archive, acquisition, rendering, and query failure paths were preserving the error message but dropping the traceback. That makes post-incident diagnosis harder, especially for the same performance and maintenance work tracked in the daemon/event-history direction.

## Solution

Update the affected logger calls in:

- `polylogue/cli/query.py`
- `polylogue/operations/archive.py`
- `polylogue/pipeline/services/acquisition.py`
- `polylogue/pipeline/services/acquisition_persistence.py`
- `polylogue/pipeline/services/ingest_batch.py`
- `polylogue/pipeline/services/rendering.py`

Ref #716

## Verification

- `git diff --check HEAD~1..HEAD`
- `ruff check polylogue/cli/query.py polylogue/operations/archive.py polylogue/pipeline/services/acquisition.py polylogue/pipeline/services/acquisition_persistence.py polylogue/pipeline/services/ingest_batch.py polylogue/pipeline/services/rendering.py`
- Pre-push hook: `devtools verify --quick` passed (`ruff format`, `ruff check`, `mypy`, `render-all`, `verify-topology`, `verify-layering`, `verify-file-budgets`, `verify-test-ownership`, `verify-schema-roundtrip`, `verify-cross-cuts`, `verify-suppressions`, `verify-manifests`, `verify-witness-lifecycle`, `proof-pack check`)
Sinity pushed a commit that referenced this pull request Sep 14, 2026
Bumps [pytest-randomly](https://github.com/pytest-dev/pytest-randomly)
from 4.1.0 to 5.0.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pytest-dev/pytest-randomly/blob/main/CHANGELOG.rst">pytest-randomly's
changelog</a>.</em></p>
<blockquote>
<h2>5.0.0 (2026-09-01)</h2>
<ul>
<li>
<p>Support Python 3.15.</p>
</li>
<li>
<p>Shuffle tests in a wrapper around the
<code>pytest_collection_modifyitems</code> hook, guaranteeing that the
shuffle runs before all other plugins’ implementations of the hook.</p>
<p>Previously, pytest-randomly shuffled in a plain <code>tryfirst</code>
hook implementation.
When another plugin also implemented the hook with
<code>tryfirst</code>, as pytest-django does, whichever plugin pytest
happened to register later ran first.
Registration order comes from package metadata on disk, which can differ
between seemingly identical environments — even two containers built
from the same <code>Dockerfile</code>, or the same virtual environment
after reinstalling a package.
As a result, the same seed could yield different test orders in
different environments.
Worse, in environments where pytest-randomly ended up shuffling last, it
silently destroyed the other plugin’s ordering — for pytest-django, the
grouping of database tests that mirrors Django’s test runner
(non-transactional database tests, then transactional ones, then the
rest).</p>
<p>Now the shuffle always runs first, and plugins that group tests with
a stable sort apply their grouping on top of the shuffled order, so the
final order is reproducible from the seed alone.
In environments that previously hit the reversed hook order, upgrading
changes the test order for a given seed — restoring both reproducibility
and other plugins’ grouping.</p>
<p><code>PR
[#746](pytest-dev/pytest-randomly#746)
&lt;https://github.com/pytest-dev/pytest-randomly/pull/746&gt;</code><strong>.
Thanks to milssky for the report in <code>Issue
[#701](pytest-dev/pytest-randomly#701)
&lt;https://github.com/pytest-dev/pytest-randomly/issues/701&gt;</code></strong>.</p>
</li>
<li>
<p>Require pytest 8+, the first version to require a version of pluggy
that supports hook wrappers, as used by the above fix.</p>
<p><code>PR
[#746](pytest-dev/pytest-randomly#746)
&lt;https://github.com/pytest-dev/pytest-randomly/pull/746&gt;</code>__.</p>
</li>
<li>
<p>Reset <code>Polyfactory
&lt;https://polyfactory.litestar.dev/&gt;</code>__\’s default random
state at the start of every test, if it is installed.</p>
<p>Thanks to Rahul Kumar in <code>PR
[#735](pytest-dev/pytest-randomly#735)
&lt;https://github.com/pytest-dev/pytest-randomly/issues/735&gt;</code>__.</p>
</li>
<li>
<p>Switch package build backend from setuptools to <code>uv_build
&lt;https://docs.astral.sh/uv/concepts/build-backend/&gt;</code>__.
This makes builds with uv about nine times faster, since uv runs the
backend natively, without creating a build environment or spawning a
Python process.
Additionally, source distributions no longer include test files, which
setuptools previously included incompletely, missing the files needed to
actually run them.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/89ddfb1025cf15a81eb3defec7554740f32bcbe3"><code>89ddfb1</code></a>
Version 5.0.0</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/0d00951e3fd85145567adfa2b638c7987f3e33ef"><code>0d00951</code></a>
Shuffle before other plugins' collection hooks (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/746">#746</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/817091daca7b0540edb45da652ffc84a766724a1"><code>817091d</code></a>
Upgrade dependencies (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/745">#745</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/42a2066ee95bdb1c606945436d7170ef3a6376c5"><code>42a2066</code></a>
Fix podcast link in README (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/740">#740</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/c2a001d37d14abc95940c923f730a07ccf87b4e2"><code>c2a001d</code></a>
Reset Polyfactory's default random state on each test (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/735">#735</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/cc4762bcb547a455b670b812ea362c483a31e7ef"><code>cc4762b</code></a>
Upgrade dependencies (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/744">#744</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/94aba4ad675e863b65f024ab924688e595fa8a3f"><code>94aba4a</code></a>
Upgrade dependencies (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/743">#743</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/c9140eff32cadcdc14d82a944e63d3ad1b4dbe8c"><code>c9140ef</code></a>
Support Python 3.15 (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/741">#741</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/15f531e2a7c1c88f27febc9c92966472d5bb18fc"><code>15f531e</code></a>
Switch build backend to uv_build (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/739">#739</a>)</li>
<li><a
href="https://github.com/pytest-dev/pytest-randomly/commit/79eee6c2f5475911d178b1a42b649182cbfc5e9f"><code>79eee6c</code></a>
[pre-commit.ci] pre-commit autoupdate (<a
href="https://redirect.github.com/pytest-dev/pytest-randomly/issues/738">#738</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/pytest-dev/pytest-randomly/compare/4.1.0...5.0.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest-randomly&package-manager=uv&previous-version=4.1.0&new-version=5.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

1 participant