Skip to content

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

Open
tomerqodo wants to merge 12 commits into
cursor_only-issues-20260113-cursor_completion_base_fixapi_surface_subscription_deletion_errors_to_users_pr181from
cursor_only-issues-20260113-cursor_completion_head_fixapi_surface_subscription_deletion_errors_to_users_pr181
Open

fix(api): surface subscription deletion errors to users#11
tomerqodo wants to merge 12 commits into
cursor_only-issues-20260113-cursor_completion_base_fixapi_surface_subscription_deletion_errors_to_users_pr181from
cursor_only-issues-20260113-cursor_completion_head_fixapi_surface_subscription_deletion_errors_to_users_pr181

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 20, 2026

Copy link
Copy Markdown

Benchmark PR from qodo-benchmark#181


Note

Streamlines trigger subscription updates and rebuilds with stricter validation and a simpler service workflow.

  • Validation: Adds @model_validator to TriggerSubscriptionUpdateRequest requiring at least one of name, credentials, parameters, or properties.
  • Update endpoint: Handles rename-only updates directly; otherwise always invokes rebuild with provided fields (falling back to existing credentials/parameters when omitted).
  • Rebuild service: Replaces lock/transaction-heavy logic with a straightforward flow: fetch subscription, validate credential type, unsubscribe then subscribe, then persist via update_trigger_subscription; no credential merging or error suppression on unsubscribe.
  • Tests: Removes cases for continuing after unsubscribe errors, provider-not-found, and unsupported credential type; retains/updates rebuild and name uniqueness coverage.

Written by Cursor Bugbot for commit 5489175. Configure here.

Mairuis and others added 12 commits December 29, 2025 18:01
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
… 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

endpoint=generate_plugin_trigger_endpoint_url(subscription.endpoint_id),
parameters=parameters,
credentials=credentials,
credential_type=credential_type,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

HIDDEN_VALUE credentials sent to third-party APIs

High Severity

The refactored rebuild_trigger_subscription removes the HIDDEN_VALUE credential merging logic. When users update subscriptions, frontends typically send HIDDEN_VALUE (like [__HIDDEN__]) for unchanged sensitive fields. The old code replaced these with actual stored credentials before calling external APIs. Now, the literal HIDDEN_VALUE string is passed directly to TriggerManager.subscribe_trigger(), causing third-party API calls (e.g., GitHub webhook creation) to receive invalid credentials and fail. The tests still expect this merging behavior, confirming it's required functionality.

Additional Locations (1)

Fix in Cursor Fix in Web

credentials=request.credentials or subscription.credentials,
parameters=request.parameters or subscription.parameters,
)
return 200

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

UNAUTHORIZED subscriptions cannot update properties anymore

Medium Severity

The manually_created variable is computed but never used. The old code had a separate branch for CredentialType.UNAUTHORIZED subscriptions that allowed updating name and properties without rebuilding. The new code only handles the "rename only" case. When an UNAUTHORIZED subscription tries to update properties (with or without name), it falls through to rebuild_trigger_subscription, which rejects UNAUTHORIZED credential types with an error. This breaks property updates for manually-created subscriptions.

Fix in Cursor Fix in Web

credentials=credentials,
properties=new_subscription.properties,
expires_at=new_subscription.expires_at,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Concurrent rebuilds cause race conditions without distributed lock

Medium Severity

The refactored rebuild_trigger_subscription removes the distributed lock (redis_client.lock with key trigger_subscription_rebuild_lock:{tenant_id}_{subscription_id}) that protected against concurrent operations. Other methods in the same service like add_trigger_subscription and update_trigger_subscription still use Redis locks. Without the lock, concurrent rebuild requests on the same subscription can cause duplicate webhook registrations at third-party services, or one request may fail confusingly because the other already unsubscribed the webhook.

Fix in Cursor Fix in Web

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