Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label mergequeue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Claude finished @mchenani's task —— View job Code Review CompleteReview Date: March 18, 2026, 06:11 UTC Critical IssueSQL Injection Vulnerability in The dynamic SQL query construction is vulnerable to SQL injection: let placeholders = message_ids
.iter()
.map(|_| "?")
.collect::<Vec<_>>()
.join(", ");
let query = format!(
"SELECT id, group_id, original_message_id, edited_by_inbox_id, edited_content, edited_at_ns
FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY original_message_id ORDER BY edited_at_ns DESC) as rn
FROM message_edits
WHERE original_message_id IN ({})
) WHERE rn = 1",
placeholders
);While the placeholders themselves are safe ( Recommendation: Use Diesel's query builder with raw SQL only for the window function part, not the entire query. Consider using a CTE or subquery that Diesel can validate at compile time. Performance ConcernMissing index on The composite index Minor Issues
Positive Observations
|
ApprovabilityVerdict: Approved Adds database schema and query infrastructure for message editing functionality. All changes are within the author's designated code ownership domain, the additions are well-tested with comprehensive unit tests, and the changes don't modify existing runtime behavior - they add new tables and query methods that will be consumed by future work. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## mc/edit-message-content-type #3343 +/- ##
===============================================================
Coverage ? 82.86%
===============================================================
Files ? 378
Lines ? 51365
Branches ? 0
===============================================================
Hits ? 42566
Misses ? 8799
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

TL;DR
Adds database support for message editing functionality with a new
message_editstable and associated query operations.What changed?
message_editstable with fields for tracking edit history including edit ID, group ID, original message ID, editor inbox ID, edited content, and timestampStoredMessageEditstruct andQueryMessageEdittrait with methods for retrieving edits by message ID, getting latest edits, and checking if messages have been editedEditMessagecontent type (17) to theContentTypeenumEditabletrait to determine which message types can be edited (only text, markdown, reply, attachment, remote attachment, transaction reference, multi remote attachment, and wallet send calls are editable)How to test?
Run the existing test suite which includes tests for:
Why make this change?
This change provides the foundational database layer needed to support message editing in XMTP conversations. The design handles out-of-order message delivery by allowing edits to arrive before original messages, and efficiently tracks edit history with proper indexing for performance.
Note
Add
message_editsdatabase table and query API for edit message supportmessage_editstable via a Diesel migration with fields forid,group_id,original_message_id,edited_by_inbox_id,edited_content, andedited_at_ns, plus indexes on(original_message_id, edited_at_ns DESC)andgroup_id.StoredMessageEditstruct andQueryMessageEdittrait with methods to fetch edits by id, original message, latest edit, batch latest edits, group edits, and existence checks.EditMessage = 17variant to theContentTypeenum, wired intoDisplay,From<String>, and DieselFromSqlconversions;is_deletablereturns false andis_editablereturns false for this type.Editabletrait (alongside existingDeletable) and adds it as a required bound onDbQuery, so all DB handle types must implementQueryMessageEdit.Macroscope summarized 2be66f4.