Skip to content

Remove Exceptions stack trace from logs - #719

Merged
MaximPlusov merged 4 commits into
integrationfrom
logs
Aug 10, 2026
Merged

Remove Exceptions stack trace from logs#719
MaximPlusov merged 4 commits into
integrationfrom
logs

Conversation

@LonelyMidoriya

@LonelyMidoriya LonelyMidoriya commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved error logging across document parsing, rendering, font handling, image processing, encryption, and stream operations.
    • Routine handled exceptions no longer produce unnecessary stack traces in log output.
    • Warning and diagnostic messages remain available while processing behavior is unchanged.
    • Log output is more concise and easier to review while preserving relevant failure information.

@LonelyMidoriya LonelyMidoriya self-assigned this Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a51ec7c3-b5cc-4b81-ad5d-78e6c4fcdc6c

📥 Commits

Reviewing files that changed from the base of the PR and between 699c9e9 and d15942a.

📒 Files selected for processing (2)
  • src/main/java/org/verapdf/cos/COSDocument.java
  • src/main/java/org/verapdf/io/Reader.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/org/verapdf/io/Reader.java
  • src/main/java/org/verapdf/cos/COSDocument.java

📝 Walkthrough

Walkthrough

This change removes caught exception arguments and direct stack-trace printing from logging and error handlers across COS, parser, document, font, image, and serialization code. Messages, log levels, control flow, and fallback behavior remain unchanged.

Changes

COS and serialization logging

Layer / File(s) Summary
COS and serialization logging
src/main/java/org/verapdf/cos/*, src/main/java/org/verapdf/cos/visitor/*
COS and PDF writer error paths no longer attach exceptions or print stack traces. Existing cleanup, fallback, and suppression behavior remains unchanged.

Document and external error logging

Layer / File(s) Summary
Document and external error logging
src/main/java/org/verapdf/io/Reader.java, src/main/java/org/verapdf/parser/PDFParser.java, src/main/java/org/verapdf/pd/PDDocument.java, src/main/java/org/verapdf/pd/colors/PDIndexed.java, src/main/java/org/verapdf/pd/encryption/StandardSecurityHandler.java, src/main/java/org/verapdf/external/*
Document, parser, decryption, color, ICC profile, and JPEG 2000 logs retain their messages and levels without throwable arguments.

Font, function, and image logging

Layer / File(s) Summary
Font, function, and image logging
src/main/java/org/verapdf/pd/font/*, src/main/java/org/verapdf/pd/function/*, src/main/java/org/verapdf/pd/images/*, src/main/java/org/verapdf/tools/StaticResources.java
Font, CMap, function, image, and resource error handlers stop emitting caught exception details while preserving their existing outcomes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: maximplusov

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing exception stack traces from log messages across the parser.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch logs

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

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

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/verapdf/cos/visitor/Writer.java (1)

126-161: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Preserve a failure signal for serialization I/O.

These catch blocks are now empty. A failed write in scalar, array, dictionary, null, header, or cross-reference serialization is treated as success. COSDocument.saveTo can then copy a partial temporary PDF and return normally.

close() also hides close failures. getOffset() converts an output error to 0, which can produce invalid cross-reference offsets.

Remove direct stack-trace printing, but log a structured message without the throwable or propagate VeraPDFParserException. Do not make serialization failures silent.

Also applies to: 164-189, 258-261, 289-292, 354-355, 372-385

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/verapdf/cos/visitor/Writer.java` around lines 126 - 161,
Update all empty I/O catches in Writer, including
scalar/array/dictionary/null/header/cross-reference visitors, close(), and
getOffset(), so serialization failures are never treated as success. Remove
direct stack-trace printing and either propagate VeraPDFParserException or emit
a structured error message without the throwable. Ensure getOffset() does not
convert output failures to 0, allowing COSDocument.saveTo to detect and reject
partial serialization.
🧹 Nitpick comments (1)
src/main/java/org/verapdf/pd/function/PDType0Function.java (1)

157-157: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align throwable logging in PDType0Function.

If the cleanup applies across the class, remove the e argument from the remaining LOGGER.log(..., e) calls at lines 297 and 319. The current mix makes stack-trace logging inconsistent for warnings in the same class.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/verapdf/pd/function/PDType0Function.java` at line 157,
Standardize warning logging in PDType0Function by removing the throwable
argument from the remaining LOGGER.log calls near the handlers at lines 297 and
319, matching the existing “Can not parse function” warning style while
preserving their warning messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/main/java/org/verapdf/cos/visitor/Writer.java`:
- Around line 126-161: Update all empty I/O catches in Writer, including
scalar/array/dictionary/null/header/cross-reference visitors, close(), and
getOffset(), so serialization failures are never treated as success. Remove
direct stack-trace printing and either propagate VeraPDFParserException or emit
a structured error message without the throwable. Ensure getOffset() does not
convert output failures to 0, allowing COSDocument.saveTo to detect and reject
partial serialization.

---

Nitpick comments:
In `@src/main/java/org/verapdf/pd/function/PDType0Function.java`:
- Line 157: Standardize warning logging in PDType0Function by removing the
throwable argument from the remaining LOGGER.log calls near the handlers at
lines 297 and 319, matching the existing “Can not parse function” warning style
while preserving their warning messages.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b786f2d6-d5b6-465d-a4c7-459bbd74c2b5

📥 Commits

Reviewing files that changed from the base of the PR and between d56121e and 558f63b.

📒 Files selected for processing (27)
  • src/main/java/org/verapdf/cos/COSArray.java
  • src/main/java/org/verapdf/cos/COSDocument.java
  • src/main/java/org/verapdf/cos/COSStream.java
  • src/main/java/org/verapdf/cos/filters/COSFilterRegistry.java
  • src/main/java/org/verapdf/cos/visitor/COSCopier.java
  • src/main/java/org/verapdf/cos/visitor/Writer.java
  • src/main/java/org/verapdf/external/ICCProfile.java
  • src/main/java/org/verapdf/external/JPEG2000.java
  • src/main/java/org/verapdf/io/Reader.java
  • src/main/java/org/verapdf/parser/PDFParser.java
  • src/main/java/org/verapdf/pd/PDDocument.java
  • src/main/java/org/verapdf/pd/colors/PDIndexed.java
  • src/main/java/org/verapdf/pd/encryption/StandardSecurityHandler.java
  • src/main/java/org/verapdf/pd/font/PDCIDFont.java
  • src/main/java/org/verapdf/pd/font/PDFont.java
  • src/main/java/org/verapdf/pd/font/cmap/CMap.java
  • src/main/java/org/verapdf/pd/font/cmap/CMapFactory.java
  • src/main/java/org/verapdf/pd/font/cmap/CMapFile.java
  • src/main/java/org/verapdf/pd/font/cmap/PDCMap.java
  • src/main/java/org/verapdf/pd/font/stdmetrics/StandardFontMetricsFactory.java
  • src/main/java/org/verapdf/pd/font/truetype/AdobeGlyphList.java
  • src/main/java/org/verapdf/pd/font/truetype/PDTrueTypeFont.java
  • src/main/java/org/verapdf/pd/font/type1/PDType1Font.java
  • src/main/java/org/verapdf/pd/font/type3/PDType3Font.java
  • src/main/java/org/verapdf/pd/function/PDType0Function.java
  • src/main/java/org/verapdf/pd/images/PDXImage.java
  • src/main/java/org/verapdf/tools/StaticResources.java
💤 Files with no reviewable changes (1)
  • src/main/java/org/verapdf/cos/visitor/COSCopier.java

@LonelyMidoriya LonelyMidoriya changed the title Logs Remove Exceptions stack trace from logs Aug 7, 2026
@MaximPlusov
MaximPlusov merged commit 14c10c0 into integration Aug 10, 2026
9 checks passed
@MaximPlusov
MaximPlusov deleted the logs branch August 11, 2026 11:38
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.

2 participants