Skip to content

fix(ai-slop): recognize logger.exception as capturing the error in silent-recovery - #355

Open
mtschoen wants to merge 3 commits into
scanaislop:developfrom
mtschoen:fix/silent-recovery-logger-exception
Open

fix(ai-slop): recognize logger.exception as capturing the error in silent-recovery#355
mtschoen wants to merge 3 commits into
scanaislop:developfrom
mtschoen:fix/silent-recovery-logger-exception

Conversation

@mtschoen

@mtschoen mtschoen commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes a false positive in the ai-slop/silent-recovery Python detector: except-blocks that log via logger.exception(...) or logger.error(..., exc_info=True) were being flagged as silently dropping the caught exception, even though both forms attach the full traceback. The detector now recognizes either pattern as capturing the error and skips the flag.

One review-driven bound: an explicit exc_info=False on the same line cancels the exemption, since Python forwards that value to Logger.error and the traceback is omitted. Any other exc_info value (a variable, an expression) stays exempt rather than guessed at, and docs/rules.md records the bound.

Test plan:

  • pnpm typecheck clean
  • tests/silent-recovery.test.ts 20/20 pass (6 new cases: bare except + logger.exception, except-as-e with unused binding, logger.error with exc_info=True, exc_info=False with and without whitespace around the =, and the pinned exc_info-bound-to-a-variable non-detection)
  • Each new test was confirmed to fail without its source fix
  • Full suite after build: 2024 passed / 14 skipped / 0 failed

🤖 Generated with Claude Code

…lent-recovery

Python's logging.Logger.exception() always attaches the currently-handled
exception's traceback (it is exactly .error(..., exc_info=True)), so an
except-block that logs via logger.exception(...) is not silently dropping
the failure cause even when the log call doesn't reference the exception
binding by name. The silent-recovery detector previously required a
literal identifier match, producing false positives on this common
pattern. Now any .exception(...) call or exc_info=True keyword argument
in the except body counts as capturing the error.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@scan-ai-slop-aislop

Copy link
Copy Markdown
Contributor

aislop skipped this PR

This workspace does not have an active paid scanaislop plan. Choose a plan to resume hosted scans and PR gates:

Choose a paid plan

This comment appears once per PR. Further pushes will be skipped silently until the workspace has paid access.

@mtschoen
mtschoen marked this pull request as ready for review August 16, 2026 00:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4091651ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/engines/ai-slop/silent-recovery.ts
The Python silent-recovery exemption matched `.exception(` unconditionally,
so an except body calling `logger.exception(..., exc_info=False)` was treated
as capturing the failure. Python forwards that value straight to
`Logger.error`, which then omits the traceback, leaving the failure cause
unobserved - exactly what the rule exists to catch.

The exemption is now cancelled when the same line spells the literal
`exc_info=False` (optional whitespace around the `=`). Only that literal is
recognized: an `exc_info` bound to a variable or an expression stays exempt,
since deciding its value would mean evaluating arbitrary Python, and
under-reporting beats misfiring on valid code. A multi-line call that puts
`exc_info=False` on a continuation line likewise stays exempt.

Regression tests cover the flagged spellings (with and without whitespace
around the `=`) and pin the deliberate non-detection; the existing
`logger.exception(e)` and `exc_info=True` exemptions are unchanged.
docs/rules.md now states the bound.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@scan-ai-slop-aislop

Copy link
Copy Markdown
Contributor

aislop scan: 100/100 (Healthy) +

Clean run — no errors, no warnings, no auto-fixable findings.

View full report

…section

The table row had grown to several times the length of its siblings;
keep a one-clause pointer in the row and hold the exemption bounds in
a "Rule notes" subsection after the table, matching how the Linting
section already breaks detail out of its tables.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mtschoen added a commit to mtschoen/aislop that referenced this pull request Aug 16, 2026
…tion exemption) into schoen/main

# Conflicts:
#	docs/rules.md
#	src/engines/ai-slop/silent-recovery.ts
#	tests/silent-recovery.test.ts
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