Skip to content

Conversation

@st-manu
Copy link
Contributor

@st-manu st-manu commented Nov 5, 2025

https://sakaiproject.atlassian.net/browse/SAK-52133

Summary by CodeRabbit

  • Bug Fixes
    • Corrected file path construction for temporary email attachments to ensure proper storage and retrieval operations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

Modified path construction for temporary email attachments in ForumsEmailService, changing from slash-formatted prefix ("/email_tmp/") to plain "email_tmp". Affects attachment file location and deletion logic. ResourceId handling updated to normalize separators.

Changes

Cohort / File(s) Change Summary
Temporary email attachment path handling
msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java
Updated path construction for temporary email attachments by removing leading and trailing slashes from the prefix (changed from "/email_tmp/" to "email_tmp"), and adjusted separator handling between directory and attachment identifiers. Modified getAttachedFile logic to normalize backslashes to forward slashes in resourceId.

Suggested reviewers

  • ottenhoff
  • jesusmmp

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the issue (SAK-52133) and clearly summarizes the main fix: email notifications not being sent when attachments are added to discussions.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1eb097 and 32c5b2c.

📒 Files selected for processing (1)
  • msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java

📄 CodeRabbit inference engine (.cursor/rules/logging-rule.mdc)

**/*.java: Use SLF4J parameterized logging (e.g., logger.info("Value is: {}", value)) instead of string concatenation in log statements
Write log messages and code comments in English; never translate log messages

**/*.java: Java: Never use local variable type inference (var). Always declare explicit types.
When proposing or writing Java code, spell out full types in local variable declarations, for-loops, and try-with-resources.
If Java code uses var, replace it with an explicit type.
Review gate: Treat any PR or suggestion containing Java var as non-compliant; require explicit types before merge.

Files:

  • msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java
🧠 Learnings (1)
📓 Common learnings
Learnt from: ottenhoff
Repo: sakaiproject/sakai PR: 0
File: :0-0
Timestamp: 2025-10-07T15:11:27.298Z
Learning: In samigo’s Total Scores view (samigo/samigo-app/src/webapp/jsf/evaluation/totalScores.jsp), mailto links were hidden after commit dee05746 (PR #12312, SAK-49674) added a render check requiring email.fromEmailAddress to be non-empty; PR #14154 (SAK-52058) restores visibility by checking only description.email.
Learnt from: CR
Repo: sakaiproject/sakai PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-07T16:11:33.008Z
Learning: Commit messages should follow: <issue key> <component> <brief description> (e.g., SAK-12345 Assignments add option x)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: maven-build
  • GitHub Check: sakai-deploy
  • GitHub Check: maven-build
🔇 Additional comments (1)
msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java (1)

273-274: Backslash normalization improves cross-platform compatibility.

The .replace('\\', '/') addition properly normalizes Windows-style path separators in resourceId, ensuring consistent forward-slash paths across platforms.

Comment on lines +256 to 259
sbPrefixedPath.append("email_tmp");
a = (Attachment) iter.next();
deleteAttachedFile(sbPrefixedPath.append(
a.getAttachmentId()).toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Path mismatch prevents attachment cleanup.

The path construction here is now inconsistent with getAttachedFile at line 273. Files are created at prefixedPath/email_tmp/resourceId but this deletion attempts prefixedPathemail_tmpattachmentId (missing separators), causing:

  • Temporary files are never deleted (resource leak)
  • Disk space accumulates over time
  • Potential system issues as temp directory fills

Apply this diff to restore consistent path construction:

-					sbPrefixedPath.append("email_tmp");
+					sbPrefixedPath.append("/email_tmp/");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sbPrefixedPath.append("email_tmp");
a = (Attachment) iter.next();
deleteAttachedFile(sbPrefixedPath.append(
a.getAttachmentId()).toString());
sbPrefixedPath.append("/email_tmp/");
a = (Attachment) iter.next();
deleteAttachedFile(sbPrefixedPath.append(
a.getAttachmentId()).toString());
🤖 Prompt for AI Agents
In
msgcntr/messageforums-app/src/java/org/sakaiproject/tool/messageforums/ForumsEmailService.java
around lines 256 to 259, the deletion path is built incorrectly by appending
"email_tmp" and attachmentId to the same StringBuilder without path separators
and by mutating sbPrefixedPath used elsewhere; change the deletion logic to
construct the path consistently with getAttachedFile (prefixedPath +
File.separator + "email_tmp" + File.separator + resourceId/attachmentId) and do
not reuse/mutate the original sbPrefixedPath (create a new StringBuilder or use
String.join/Paths.get) so the final string matches the created file path and
temporary files are actually deleted.

@github-actions
Copy link

This PR has been automatically marked as stale due to 10 days of inactivity. It will be closed in 4 days unless there is new activity.

@github-actions github-actions bot added the stale label Nov 18, 2025
@st-manu st-manu removed the stale label Nov 18, 2025
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