Skip to content

fix(api): surface subscription deletion errors to users#30333

Merged
crazywoola merged 11 commits intomainfrom
fix/surface-subscription-deletion-errors
Jan 5, 2026
Merged

fix(api): surface subscription deletion errors to users#30333
crazywoola merged 11 commits intomainfrom
fix/surface-subscription-deletion-errors

Conversation

@Mairuis
Copy link
Contributor

@Mairuis Mairuis commented Dec 29, 2025

Summary

This PR fixes a bug where trigger subscription deletion/unsubscribe errors were silently ignored during the rebuild process.

  • Check UnsubscribeResult.success and propagate error messages to users when unsubscribe fails
  • Simplify rebuild logic by removing unnecessary try/except wrapper around unsubscribe
  • Refactor update API to use cleaner conditional logic with any()
  • Remove redundant test cases that validated silent error handling behavior

Fixes #30332

Test Plan

  • Verify that unsubscribe errors are now properly surfaced to users with clear error messages
  • Verify that successful subscription rebuilds continue to work as expected
  • Run existing unit tests to ensure no regressions
Previously, when rebuilding a trigger subscription, errors from the unsubscribe operation were silently caught and logged without propagating to the user. This left users unaware of failures during subscription management. Changes: - Check UnsubscribeResult.success and raise ValueError with the error message when unsubscribe fails - Simplify the rebuild logic by removing unnecessary try/except wrapper - Refactor update API to use cleaner conditional logic - Remove redundant test cases that tested silent error handling
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 29, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Mairuis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug where errors occurring during the deletion or unsubscription of triggers were silently ignored, leading to a poor user experience. The changes ensure that such errors are now properly surfaced to users, providing clear feedback when a subscription rebuild fails. Additionally, the PR includes refactoring to simplify the update and rebuild logic within the API, making the codebase more robust and maintainable.

Highlights

  • Error Handling: Subscription deletion/unsubscribe errors are now explicitly checked using UnsubscribeResult.success and propagated to users, preventing silent failures during the rebuild process.
  • Code Simplification: The rebuild logic has been simplified by removing an unnecessary try/except wrapper around the unsubscribe operation, and the update API now uses cleaner conditional logic with any().
  • Test Refactoring: Redundant test cases that previously validated silent error handling behavior for unsubscribe failures have been removed, aligning tests with the new error surfacing logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request refactors the trigger subscription update and rebuild logic. The trigger_providers.py controller was simplified to handle different update scenarios (name-only, unauthorized subscriptions, and general rebuilds), moving credential merging logic out. The rebuild_trigger_subscription service method was significantly refactored to remove distributed locking and direct session management, instead performing an explicit unsubscribe followed by a new subscription, and delegating the final database update. This change also made unsubscribe failures explicit errors rather than gracefully handled exceptions. Consequently, two related tests were removed: one for gracefully handling unsubscribe errors and another for the 'provider not found' scenario. The review comment specifically requests re-adding the 'provider not found' test, emphasizing its importance for regression testing given that the provider existence check logic still exists in the rebuild_trigger_subscription method.

I am having trouble creating individual review comments. Click here to see my feedback.

api/tests/test_containers_integration_tests/services/test_trigger_provider_service.py (561-587)

medium

The test test_rebuild_trigger_subscription_provider_not_found has been removed. This test is valuable as it ensures that the system correctly handles cases where a provider is not found during a subscription rebuild. The logic to check for a provider's existence is still present in rebuild_trigger_subscription, so this test remains relevant for regression testing. Please consider re-adding it.

… TriggerSubscriptionUpdateRequest - Introduced a model validator in TriggerSubscriptionUpdateRequest to enforce that at least one of the fields (name, credentials, parameters, properties) must be provided. - Refactored the TriggerSubscriptionUpdateApi to use the validated request object and simplified the logic for updating subscriptions based on the credential type. - Updated the credential type check in TriggerProviderService to use a set for better performance and clarity.
…oviderService - Deleted the test for rebuilding trigger subscriptions with unsupported credential types, as it was deemed unnecessary. - This change helps streamline the test suite by focusing on relevant scenarios.
@Mairuis Mairuis requested a review from Yeuoly December 30, 2025 04:26
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

4 participants