Skip to content

fix(log): say each cause once when wrappers repeat their cause's message - #633

Merged
linroid merged 1 commit into
mainfrom
fix/log-repeated-cause-messages
Oct 23, 2026
Merged

linroid merged 1 commit into
mainfrom
fix/log-repeated-cause-messages

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Problem

describeCauses() builds the one-line cause chains in warnings, in the CLI's Download failed: line and in the apps' error details. It only dropped a message that was exactly cause.toString(). The JDK's TLS errors end each wrapper's message with its cause's message or toString(), so a certificate failure printed the same text three times:

Download failed: Network: Network error occurred <- FailedRequest: GET https://expired.badssl.com/ <- SSLHandshakeException: (certificate_expired) PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed <- ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed <- CertPathValidatorException: validity check failed <- CertificateExpiredException: NotAfter: Mon Apr 13 07:59:59 SGT 2015

Fix

Each entry now keeps only what it adds to its cause:

  • A message ending with cause.toString() drops that part, along with the colon before it.
  • A message ending with the cause's message drops it too, when that message is 16 characters or more and follows a space or colon. So Stream closed caused by closed keeps its words.
  • A copy that coroutines' stack-trace recovery makes of an exception (same class and message as its cause) is left out, instead of now showing as a bare class name.
Download failed: Network: Network error occurred <- FailedRequest: GET https://expired.badssl.com/ <- SSLHandshakeException: (certificate_expired) <- ValidatorException: PKIX path validation failed <- CertPathValidatorException: validity check failed <- CertificateExpiredException: NotAfter: Mon Apr 13 07:59:59 SGT 2015

Tests

  • LogFormatTest: a JDK-style chain of wrappers, a short cause message that is kept, and a recovered copy listed once.
  • KtorHttpEngineTest, the CLI tests and ErrorCopyTest pass unchanged.
  • Checked by hand with the CLI against expired.badssl.com, untrusted-root.badssl.com and an unknown host.

describeCauses only skipped a message equal to cause.toString(). The
JDK's TLS errors end each wrapper's message with its cause's message or
toString(), so an expired certificate read:

  SSLHandshakeException: (certificate_expired) PKIX path validation
  failed: java.security.cert.CertPathValidatorException: validity check
  failed <- ValidatorException: PKIX path validation failed:
  java.security.cert.CertPathValidatorException: validity check failed
  <- CertPathValidatorException: validity check failed <- ...

Now each entry keeps only what it adds: a message ending with
cause.toString(), or with the cause's message (16 characters or more,
after a space or colon), drops that part, and a copy coroutines recover
of an exception is left out:

  SSLHandshakeException: (certificate_expired) <- ValidatorException:
  PKIX path validation failed <- CertPathValidatorException: validity
  check failed <- CertificateExpiredException: NotAfter: ...
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T18:27:00.634325Z 7ba0551 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 2 200 files  ±0   2 228 suites  ±0   56m 59s ⏱️ -46s
15 376 tests +9  15 108 ✅ +9  268 💤 ±0  0 ❌ ±0 
18 735 runs  +9  18 467 ✅ +9  268 💤 ±0  0 ❌ ±0 

Results for commit 7ba0551. ± Comparison against base commit d3c7122.

♻️ This comment has been updated with latest results.

@linroid
linroid merged commit b9ead2e into main Oct 23, 2026
25 of 28 checks passed
@linroid
linroid deleted the fix/log-repeated-cause-messages branch October 23, 2026 20:17
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