Skip to content

Remove corrupted file answer and improve logs#492

Merged
rob93c merged 8 commits intomainfrom
fix-corrupted-file-answer
Apr 21, 2026
Merged

Remove corrupted file answer and improve logs#492
rob93c merged 8 commits intomainfrom
fix-corrupted-file-answer

Conversation

@rob93c
Copy link
Copy Markdown
Member

@rob93c rob93c commented Apr 18, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Removed the specialised "corrupted" reply; users now receive a single, consistent error response when media processing fails.
    • Error text now refers to "the media" (not specifically "the video") for clearer, more accurate messaging.
    • Unhandled message logs now include original request context to aid issue diagnosis.
  • Chores

    • Improved structured logging and error-handling to provide better diagnostic context and more consistent log keys.
  • Tests

    • A test covering the previous "corrupted" reply scenario was removed.

@rob93c rob93c requested a review from MartelliEnrico April 18, 2026 10:05
@rob93c rob93c self-assigned this Apr 18, 2026
@rob93c rob93c added enhancement New feature or request logs This marks changes revolving around logs labels Apr 18, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb7869b7-04d8-4634-afe2-a9d15d2a6fd8

📥 Commits

Reviewing files that changed from the base of the PR and between 515945c and 3226753.

⛔ Files ignored due to path filters (1)
  • src/test/resources/corrupted.mp4 is excluded by !**/*.mp4
📒 Files selected for processing (1)
  • src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java

📝 Walkthrough

Walkthrough

Renamed and consolidated structured-logging scoped values and log-key constants; updated call sites to use the new keys; removed CorruptedFileException and the CORRUPTED reply/tests; unified exception handling and logging for file processing and temp-file cleanup.

Changes

Cohort / File(s) Summary
Structured logger constants
src/main/java/com/github/stickerifier/stickerify/logger/StructuredLogger.java
Renamed exported ScopedValue keys (REQUEST_DETAILSREQUEST_DETAILS_VALUE, MIME_TYPEMIME_TYPE_VALUE), added FILE_ID_VALUE, and introduced log-key constants (EXCEPTION_MESSAGE_LOG_KEY, ORIGINAL_REQUEST_LOG_KEY, FILE_PATH_LOG_KEY, STICKER_LOG_KEY). Updated at(Level) to read new scoped values.
Bot control & logging
src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java
Switched request-scoped context to REQUEST_DETAILS_VALUE; wrap downloadable answerFile calls in FILE_ID_VALUE context; replaced CorruptedFileException-specific handling with unified ERROR reply and use of EXCEPTION_MESSAGE_LOG_KEY/ORIGINAL_REQUEST_LOG_KEY/FILE_PATH_LOG_KEY.
Media conversion & logging
src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java
Store detected MIME in MIME_TYPE_VALUE; replace ad-hoc file/sticker log keys with FILE_PATH_LOG_KEY/STICKER_LOG_KEY; consolidate media metadata errors to MediaException and map parsing/process errors to MediaException.
Telegram replies & tests
src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java, src/test/java/com/github/stickerifier/stickerify/bot/MockResponses.java, src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java
Removed CORRUPTED reply constant, deleted CORRUPTED_FILE mock and the corruptedVideo() test.
Exception type removal
src/main/java/com/github/stickerifier/stickerify/exception/CorruptedFileException.java
Deleted the CorruptedFileException class and constructor; callers now use MediaException.
Logging configuration
src/main/resources/logback.xml
Renamed console appender from JSON_CONSOLE to CONSOLE and removed explicit JSON timestamp provider configuration.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Client as "Telegram Client"
    participant Bot as "Stickerify Bot"
    participant Media as "MediaHelper"
    participant FS as "Filesystem"
    participant Logger as "StructuredLogger"

    Client->>Bot: send media message
    Bot->>Logger: set REQUEST_DETAILS_VALUE
    Bot->>Media: validate & convert media
    Media->>Logger: set MIME_TYPE_VALUE
    Media->>FS: create temp files / run ffmpeg
    FS-->>Media: temp file path / result
    Media->>Logger: log FILE_PATH_LOG_KEY / STICKER_LOG_KEY
    Media-->>Bot: converted file or MediaException
    alt converted file
        Bot->>Logger: set FILE_ID_VALUE
        Bot->>Client: send converted file
    else MediaException
        Bot->>Logger: log EXCEPTION_MESSAGE_LOG_KEY and ORIGINAL_REQUEST_LOG_KEY
        Bot->>Client: send ERROR reply
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested Reviewers

  • MartelliEnrico

Poem

🐇 I hopped through keys both new and old,
Scoped-values snug in burrows bold,
I chewed the test that cried "corrupted"—gone,
Logs now whisper clear from dusk to dawn,
A happy hop for every changed line!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately reflects the main changes: removal of the corrupted file answer enum constant and improvements to structured logging throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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 and usage tips.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 18, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 19, 2026
@rob93c rob93c changed the title Fix corrupted file answer and improve logs Remove corrupted file answer and improve logs Apr 19, 2026
Copy link
Copy Markdown
Contributor

@MartelliEnrico MartelliEnrico left a comment

Choose a reason for hiding this comment

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

please see in file comments

Comment thread src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java Outdated
Comment thread src/main/resources/logback.xml
Copy link
Copy Markdown
Contributor

@MartelliEnrico MartelliEnrico left a comment

Choose a reason for hiding this comment

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

LGTM

@rob93c rob93c merged commit 0ba213d into main Apr 21, 2026
8 checks passed
@rob93c rob93c deleted the fix-corrupted-file-answer branch April 21, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request logs This marks changes revolving around logs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants