Skip to content

ADFA-2801 | Prevent oversized feedback email payloads#925

Merged
jatezzz merged 3 commits intostagefrom
fix/ADFA-2801-feedback-email-transaction-too-large
Feb 11, 2026
Merged

ADFA-2801 | Prevent oversized feedback email payloads#925
jatezzz merged 3 commits intostagefrom
fix/ADFA-2801-feedback-email-transaction-too-large

Conversation

@jatezzz
Copy link
Collaborator

@jatezzz jatezzz commented Feb 4, 2026

Description

This PR prevents TransactionTooLargeException when sending feedback by truncating oversized email body content before building the intent, while keeping full logs available via file attachments. It also removes the pre-flight resolveActivity() check and relies on a safe startActivity() call with a user-facing fallback.

Details

Sentry showed TransactionTooLargeException (~15 MB parcel) triggered during intent resolution/start due to an oversized Intent.EXTRA_TEXT payload; the email body is now bounded to a safe size to avoid Binder limits.

Before changes

Screen.Recording.2026-02-04.at.11.04.59.AM.mov

After changes

Screen.Recording.2026-02-04.at.11.13.09.AM.mov

Ticket

ADFA-2801

Observation

The issue was caused by large diagnostic text being included directly in the email body; limiting EXTRA_TEXT keeps the intent payload within Binder limits without changing attachment behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added a public MAX_EMAIL_BODY_CHARS and sanitizeEmailBody to FeedbackEmailHandler to truncate long email bodies; FeedbackManager now uses exception-based startActivity handling (distinguishing ActivityNotFoundException and TransactionTooLargeException) when launching the email intent; added string resource msg_feedback_log_too_long.

Changes

Cohort / File(s) Summary
Email Body Sanitization
common/src/main/java/com/itsaky/androidide/utils/FeedbackEmailHandler.kt
Added public MAX_EMAIL_BODY_CHARS; introduced private sanitizeEmailBody(body: String, hasLogAttachment: Boolean = true): String to truncate long bodies and append a truncation notice; getIntentBasedOnAttachments() now computes and reuses the sanitized body for both attachment and no-attachment branches.
Exception-Based Error Handling
common/src/main/java/com/itsaky/androidide/utils/FeedbackManager.kt
Replaced pre-flight resolveActivity check with runCatching { startActivity(emailIntent) }; catches ActivityNotFoundException (shows "no email app" toast), detects TransactionTooLargeException (logs error and shows msg_feedback_log_too_long toast), and posts a ReportCaughtExceptionEvent for other failures.
User Messaging (strings)
resources/src/main/res/values/strings.xml
Added new string resource msg_feedback_log_too_long with the message indicating the log is too large to send directly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FeedbackMgr as FeedbackManager
    participant EmailHandler as FeedbackEmailHandler
    participant System as Email App / OS

    User->>FeedbackMgr: Request send feedback
    FeedbackMgr->>EmailHandler: Build email intent (body, attachments)
    EmailHandler->>EmailHandler: sanitizeEmailBody(body, hasLogAttachment) -> safeBody
    EmailHandler-->>FeedbackMgr: Return intent with safeBody
    FeedbackMgr->>System: startActivity(emailIntent)
    alt Email app opens
        System-->>User: Email composer shown
    else ActivityNotFoundException thrown
        System--X FeedbackMgr: ActivityNotFoundException
        FeedbackMgr->>User: Show "no email app" toast
    else TransactionTooLargeException thrown
        System--X FeedbackMgr: TransactionTooLargeException
        FeedbackMgr->>System: Log error
        FeedbackMgr->>User: Show "log too large" toast
    else Other exception
        System--X FeedbackMgr: Exception
        FeedbackMgr->>System: Post ReportCaughtExceptionEvent
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

🐇 I nibble bytes and trim the scroll,
Safe notes hop out to meet their goal,
If mail apps hide or logs run long,
I thump the ground and sing this song,
Tiny rabbit, firm and droll.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title 'ADFA-2801 | Prevent oversized feedback email payloads' directly and clearly describes the main objective of the PR: preventing TransactionTooLargeException by truncating oversized email payloads.
Description check ✅ Passed The description is well-related to the changeset, clearly explaining the problem (TransactionTooLargeException from ~15 MB parcel), the solution (truncating email body content), and implementation details.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ADFA-2801-feedback-email-transaction-too-large

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

@jatezzz jatezzz requested a review from a team February 4, 2026 17:35
@jatezzz jatezzz force-pushed the fix/ADFA-2801-feedback-email-transaction-too-large branch 2 times, most recently from c307d7d to ba9252d Compare February 4, 2026 21:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@common/src/main/java/com/itsaky/androidide/utils/FeedbackEmailHandler.kt`:
- Around line 42-44: The truncation footer currently always says "See attached
file." even when getLogUri failed and no attachment exists; update the
truncation text generation in FeedbackEmailHandler (the append(...) block
building the footer) to conditionally include "See attached file." only when a
log attachment is actually present (e.g., based on a hasLogAttachment flag or by
checking attachmentUris contains the log URI), otherwise produce a generic
message like "(Log truncated: X chars omitted.)"; also update the call site that
builds the email to pass a boolean hasLogAttachment (or to set/track log
attachment presence separately when calling the builder), and ensure getLogUri
failure leaves attachmentUris empty so the condition is reliable.

@jatezzz jatezzz force-pushed the fix/ADFA-2801-feedback-email-transaction-too-large branch 3 times, most recently from 6f95c8d to b3265ab Compare February 6, 2026 13:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@common/src/main/java/com/itsaky/androidide/utils/FeedbackManager.kt`:
- Around line 344-362: The exception handling block in FeedbackManager is
missing cases where e is a TransactionTooLargeException (not just wrapped), and
the fallback branch provides no user feedback; update the when block to treat
both "e is TransactionTooLargeException" and "e is RuntimeException && e.cause
is TransactionTooLargeException" the same way (log via logger.error and show
Toast with R.string.msg_feedback_log_too_long), and in the else branch add a
user-facing Toast (e.g., generic "feedback failed" message) before posting
ReportCaughtExceptionEvent and calling EventBus.getDefault().post; reference the
existing variables/methods e, logger.error, Toast.makeText,
ReportCaughtExceptionEvent, and getCurrentScreenName(activity) when making these
changes.
🧹 Nitpick comments (1)
common/src/main/java/com/itsaky/androidide/utils/FeedbackEmailHandler.kt (1)

157-162: Parameter attachmentUris should be List<Uri> instead of MutableList<Uri>.

The function only reads from this list. Accepting MutableList unnecessarily widens the contract.

Suggested change
     fun getIntentBasedOnAttachments(
         emailRecipient: String,
         subject: String,
         body: String,
-        attachmentUris: MutableList<Uri>
+        attachmentUris: List<Uri>
     ): Intent {

@jatezzz jatezzz force-pushed the fix/ADFA-2801-feedback-email-transaction-too-large branch from e763a16 to 4a33126 Compare February 6, 2026 15:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@common/src/main/java/com/itsaky/androidide/utils/FeedbackEmailHandler.kt`:
- Line 163: The sanitized body is computed before checking attachments so
sanitizeEmailBody(body) uses the default hasLogAttachment=true and may mention
an attachment that doesn't exist; fix by deriving hasLogAttachment from the
actual inputs (e.g., attachmentUris.isNotEmpty() or whether getLogUri succeeded)
or by moving the safeBody calculation into the branch that knows if an
attachment exists, and update prepareEmailIntent (and its callers) to accept and
pass that hasLogAttachment flag so sanitizeEmailBody(body, hasLogAttachment) is
called with the correct value; locate usages in FeedbackEmailHandler.kt
(sanitizeEmailBody, prepareEmailIntent, attachmentUris, getLogUri) and adjust
accordingly.

@jatezzz jatezzz force-pushed the fix/ADFA-2801-feedback-email-transaction-too-large branch 2 times, most recently from f68203a to 9d270ed Compare February 10, 2026 13:32
@jatezzz jatezzz force-pushed the fix/ADFA-2801-feedback-email-transaction-too-large branch from 9d270ed to f73ceb5 Compare February 11, 2026 13:16
@jatezzz jatezzz force-pushed the fix/ADFA-2801-feedback-email-transaction-too-large branch from f73ceb5 to c4034aa Compare February 11, 2026 13:23
@jatezzz jatezzz merged commit fe63bb1 into stage Feb 11, 2026
2 checks passed
@jatezzz jatezzz deleted the fix/ADFA-2801-feedback-email-transaction-too-large branch February 11, 2026 13:29
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