Skip to content

feat(integrations): slack staging app sidegrade#111687

Draft
alexsohn1126 wants to merge 10 commits intoalexsohn/seer-explorer-slack-integration-cleanupfrom
alexsohn/slack-staging-sidegrade
Draft

feat(integrations): slack staging app sidegrade#111687
alexsohn1126 wants to merge 10 commits intoalexsohn/seer-explorer-slack-integration-cleanupfrom
alexsohn/slack-staging-sidegrade

Conversation

@alexsohn1126
Copy link
Copy Markdown
Member

@alexsohn1126 alexsohn1126 commented Mar 26, 2026

Summary

Adds the ability to sidegrade an organization's Slack integration between production and staging apps by swapping credentials in-place on the existing Integration row.

Backend changes (src/):

  • organization_integration_setup.py: Gate use_staging=1 query param behind the organizations:slack-staging-app feature flag; pass use_staging config into the integration pipeline.
  • slack/integration.py: Propagate use_staging config through the identity pipeline. Set installation_type to "staging" or "born_as_bot" in build_integration() based on the config.
  • identity/slack/provider.py: Return staging OAuth client ID/secret from slack-staging.* options when use_staging is set.
  • slack/requests/base.py: Fall back to the staging signing secret when the production secret fails, so webhooks from either app are accepted.

Test changes (tests/):

  • test_slack_staging_sidegrade.py (new): Tests for setup gating, identity provider credential selection, build_integration() metadata, signing secret fallback, and end-to-end sidegrade flows (production → staging → production).
  • test_helpers.py (new): Extracted assert_slack_setup_flow() from SlackIntegrationTest into a shared helper so both SlackIntegrationTest and SlackStagingSidegradeFlowTest can reuse it.
  • test_integration.py: assert_setup_flow now delegates to the shared helper, with a new init_params argument for passing query params (e.g. use_staging=1) during the OAuth init step.

alexsohn1126 and others added 7 commits March 26, 2026 11:03
Route OAuth credentials to the staging Slack app when use_staging=1 is
passed as a query parameter during the integration setup flow. The
sidegrade swaps the existing integration's credentials in place, so all
alert rules and notification preferences continue to work.

- Read use_staging from query params and gate behind slack-staging-app
  feature flag in OrganizationIntegrationSetupView
- Forward use_staging through the identity pipeline so the OAuth flow
  uses slack-staging.client-id and slack-staging.client-secret
- Set installation_type to "staging" in integration metadata
- Try staging signing secret as fallback in webhook authorization

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace SlackPromptLinkMessageBuilder with a SlackRenderable built from
slack_sdk block objects, matching the interface expected by
send_threaded_ephemeral_message. Extract the renderable construction
into _build_link_identity_renderable for reuse and testability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The custom message parameter is no longer needed since the link
identity prompt now uses SlackRenderable directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 26, 2026
@alexsohn1126 alexsohn1126 changed the title Alexsohn/slack staging sidegrade feat(integrations): slack staging app sidegrade Mar 26, 2026
Add SlackStagingSidegradeFlowTest using IntegrationTestCase to test the
end-to-end sidegrade flow (production -> staging -> production). Reuse
assert_setup_flow from SlackIntegrationTest with a new init_params
parameter to support passing query params like use_staging=1 during
the OAuth init step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use a thin wrapper method that delegates to SlackIntegrationTest's
assert_setup_flow instead of assigning the unbound method directly,
which mypy rejects due to self-type mismatch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the Slack OAuth setup flow assertion logic from
SlackIntegrationTest into a standalone assert_slack_setup_flow()
function in tests/sentry/integrations/slack/test_helpers.py. Both
SlackIntegrationTest and SlackStagingSidegradeFlowTest now delegate
to it, fixing mypy errors from cross-class method reuse.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant