Skip to content

Conversation

@cfm
Copy link
Member

@cfm cfm commented Nov 21, 2025

Closes #7707 by adding a source_conversation_truncated event that deletes items in a source's collection up to and including the specified interaction count.

While I was here, I also added more try/catch logic around exceptions from utility functions for parity with the v1 API endpoints.

Test plan

Does this give us everything we want for a "source conversation deleted"‒like event without requiring strict versioning?

Checklist

This change accounts for:

  • any required additional documentation
  • any necessary AppArmor changes (added or removed application files)
  • any impact on new SecureDrop installs and upgrades
  • our dependency update policy

@cfm cfm force-pushed the 7707-source-conversation-truncated branch from 09f3229 to fabbe9d Compare November 21, 2025 18:45
@cfm cfm requested a review from Copilot November 21, 2025 18:45
Copilot finished reviewing on behalf of cfm November 21, 2025 18:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements support for the SOURCE_CONVERSATION_TRUNCATED event type in API v2, which allows selective deletion of items in a source's collection based on interaction counts. The key changes enable partial conversation cleanup without requiring strict versioning.

  • Adds SOURCE_CONVERSATION_TRUNCATED event type with associated data class containing an upper_bound parameter
  • Introduces MultiStatus (207) status code for operations where some deletions succeed and others fail
  • Implements handle_source_conversation_truncated handler that deletes items with interaction_count ≤ upper_bound
  • Adds error handling for delete_collection failures with InternalServerError (500) status code
  • Updates API documentation to reflect MultiStatus in the event processing state machine

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
securedrop/journalist_app/api2/types.py Adds SOURCE_CONVERSATION_TRUNCATED event type, SourceConversationTruncatedData class, MultiStatus and InternalServerError status codes
securedrop/journalist_app/api2/events.py Implements handle_source_conversation_truncated handler, adds error handling to handle_source_deleted, registers new event handler
API2.md Updates state machine diagram to include MultiStatus status code in idempotency and success branches

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cfm cfm force-pushed the 7707-source-conversation-truncated branch from f8ca800 to 4373340 Compare November 21, 2025 19:00
@cfm cfm requested a review from Copilot November 21, 2025 19:00
Copilot finished reviewing on behalf of cfm November 21, 2025 19:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cfm cfm force-pushed the 7707-source-conversation-truncated branch from 4373340 to 8a15184 Compare November 21, 2025 19:34
@cfm cfm requested a review from Copilot November 21, 2025 19:34
@cfm cfm changed the title 7707 source conversation truncated feat(api2): support conversation truncation via source_convresation_truncated event Nov 21, 2025
@cfm cfm changed the title feat(api2): support conversation truncation via source_convresation_truncated event feat(api2): support conversation truncation via source_conversation_truncated event Nov 21, 2025
Copilot finished reviewing on behalf of cfm November 21, 2025 19:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cfm added 4 commits November 21, 2025 11:52
A "source_conversation_truncated" event involves deleting all the items
in the source's collection with interaction counts less than or equal to
the specified upper bound, assumed to be the last item known to the
client.  This achieves the same consistency as a
"source_conversation_deleted" event without requiring its strict
versioning.
@cfm cfm force-pushed the 7707-source-conversation-truncated branch from 8a15184 to 1a07cbd Compare November 21, 2025 19:53
@cfm cfm requested a review from Copilot November 21, 2025 19:54
Copilot finished reviewing on behalf of cfm November 21, 2025 19:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cfm cfm force-pushed the 7707-source-conversation-truncated branch from aa681cc to 6c280c0 Compare November 21, 2025 20:02
@cfm cfm requested a review from Copilot November 21, 2025 20:02
Copilot finished reviewing on behalf of cfm November 21, 2025 20:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cfm cfm added this to SecureDrop Nov 21, 2025
@cfm cfm moved this to Ready For Review in SecureDrop Nov 21, 2025
@cfm cfm marked this pull request as ready for review November 21, 2025 20:08
@cfm cfm requested a review from a team as a code owner November 21, 2025 20:08
@cfm cfm force-pushed the 7707-source-conversation-truncated branch 2 times, most recently from 8fe93da to 115d03f Compare November 21, 2025 20:31
@legoktm legoktm self-assigned this Nov 24, 2025
Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

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

Looks good, just one minor comment.

I assume that once the app is migrated we'll get rid of SOURCE_CONVERSATION_DELETED?

@legoktm legoktm moved this from Ready For Review to Under Review in SecureDrop Nov 24, 2025
@cfm cfm force-pushed the 7707-source-conversation-truncated branch from 115d03f to 16b7336 Compare November 24, 2025 19:37
@cfm
Copy link
Member Author

cfm commented Nov 24, 2025

@legoktm in #7723 (review):

I assume that once the app is migrated we'll get rid of SOURCE_CONVERSATION_DELETED?

Might as well. Truncation should be easier both to understand and implement, so I don't see a compelling reason to keep deletion around.

@cfm cfm requested a review from legoktm November 24, 2025 19:42
Copy link
Member

@legoktm legoktm left a comment

Choose a reason for hiding this comment

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

Thanks!

@legoktm legoktm added this pull request to the merge queue Nov 24, 2025
Merged via the queue into develop with commit a252cf9 Nov 24, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from Under Review to Done in SecureDrop Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

source_conversation_deleted event: truncate by interaction count

3 participants