Skip to content

chore(integrations): log Jira issue.updated webhook payloads behind a flag#114822

Merged
hobzcalvin merged 6 commits into
masterfrom
log-jira-issue-updated-webhook
May 7, 2026
Merged

chore(integrations): log Jira issue.updated webhook payloads behind a flag#114822
hobzcalvin merged 6 commits into
masterfrom
log-jira-issue-updated-webhook

Conversation

@hobzcalvin
Copy link
Copy Markdown
Contributor

Adds a temporary organizations:jira-issue-updated-payload-logging Flagpole feature that, when enabled for a linked org, causes the Jira Cloud issue.updated webhook handler to log the full webhook payload plus a focused log line whenever the changelog contains a project change. We need this data to design issue-link rewriting when a Jira issue is moved between projects.

Resolves ISWF-1512

@hobzcalvin hobzcalvin requested review from a team as code owners May 4, 2026 23:44
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 4, 2026

@hobzcalvin hobzcalvin requested a review from GabeVillalobos May 4, 2026 23:45
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 4, 2026
Comment thread src/sentry/integrations/jira/webhooks/issue_updated.py Outdated
Comment thread src/sentry/integrations/jira/webhooks/issue_updated.py Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7bfa989. Configure here.

Comment thread src/sentry/integrations/jira/webhooks/issue_updated.py
Comment thread src/sentry/integrations/jira/webhooks/issue_updated.py Outdated
@hobzcalvin hobzcalvin force-pushed the log-jira-issue-updated-webhook branch from 0bf2e52 to 127d2f7 Compare May 5, 2026 20:26
hobzcalvin and others added 3 commits May 5, 2026 14:47
… flag

Adds a temporary `organizations:jira-issue-updated-payload-logging`
Flagpole feature that, when enabled for a linked org, causes the Jira
Cloud `issue.updated` webhook handler to log the full webhook payload
plus a focused log line whenever the changelog contains a `project`
change. We need this data to design issue-link rewriting when a Jira
issue is moved between projects.
…ogging errors

The temporary `_payload_logging_enabled` feature-flag check makes RPC
calls (`integration_service.organization_contexts` plus per-org
`organization_service.get_organization_by_id`) on every issue.updated
webhook before the real handlers run. Any transient RPC failure
propagated up and turned into a 500, skipping `handle_assignee_change`
and `handle_status_change` entirely.

Wrap the diagnostic block in `try/except` so failures are reported via
`logger.exception` but the webhook still drives assignee and status
sync. Add a regression test that forces `_payload_logging_enabled` to
raise and asserts the assignee handler still runs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ogging check

The newly-added `_payload_logging_enabled` check fanned out one
`organization_service.get_organization_by_id` RPC per linked Sentry org
just to evaluate a feature flag, on every webhook regardless of whether
the flag was on for any org. A Jira integration shared by N orgs paid N
RPCs per `issue.updated` webhook.

Replace the per-org `get_organization_by_id` loop with a single batched
`Organization.objects.get_many_from_cache(...)`. The endpoint is
`@cell_silo_endpoint`, so the region-cache path is always available.

Net per webhook: 0 per-org `get_organization_by_id` calls in the feature
check, down from N.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hobzcalvin hobzcalvin force-pushed the log-jira-issue-updated-webhook branch from 127d2f7 to 9f8a7ae Compare May 5, 2026 21:47
Comment thread src/sentry/integrations/jira/webhooks/issue_updated.py Outdated
Comment thread src/sentry/integrations/jira/webhooks/issue_updated.py Outdated
hobzcalvin and others added 3 commits May 5, 2026 15:47
…ging check

`bind_org_context_from_integration` already resolves the integration's
linked org(s) to bind them to the SDK scope. Have it return the bound
`RpcOrganization` (or `None` for zero-org and ambiguous multi-org
installations) so callers that need the org for follow-up work can
reuse it instead of re-fetching it.

Use the returned org in the Jira `issue.updated` payload-logging check.
This drops the per-org `get_organization_by_id` fan-out (previously N
RPCs per webhook for a Jira installation linked to N Sentry orgs) and
keeps all integration-id-to-org resolution logic in a single place.

Behavior change: ambiguous multi-tenant Jira installations (one Jira
workspace shared by multiple Sentry orgs) no longer trigger payload
logging. This is intentional — we shouldn't dump one tenant's webhook
payloads into our diagnostic logs because a different tenant on the
same workspace flipped the flag.

The other three callers of `bind_org_context_from_integration`
(`slack/webhooks/action.py`, `jira/webhooks/uninstalled.py`,
`jira/webhooks/installed.py`) ignore the new return value.

Co-authored-by: Cursor <cursoragent@cursor.com>
The helper had collapsed to a one-liner (`org is not None and features.has(...)`)
that was only worth keeping to preserve the existing test mock. Inline it,
and switch the failure-path test to mock `logger.info` instead — the test
now exercises the real feature-flag check end-to-end via `@with_feature`,
which is closer to the failure mode the try/except is actually guarding.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hobzcalvin hobzcalvin requested a review from GabeVillalobos May 6, 2026 19:38
@hobzcalvin hobzcalvin merged commit 1bba418 into master May 7, 2026
82 checks passed
@hobzcalvin hobzcalvin deleted the log-jira-issue-updated-webhook branch May 7, 2026 19:48
constantinius pushed a commit that referenced this pull request May 8, 2026
… flag (#114822)

Adds a temporary `organizations:jira-issue-updated-payload-logging`
Flagpole feature that, when enabled for a linked org, causes the Jira
Cloud `issue.updated` webhook handler to log the full webhook payload
plus a focused log line whenever the changelog contains a `project`
change. We need this data to design issue-link rewriting when a Jira
issue is moved between projects.

Resolves ISWF-1512

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
nikkikapadia pushed a commit that referenced this pull request May 12, 2026
… flag (#114822)

Adds a temporary `organizations:jira-issue-updated-payload-logging`
Flagpole feature that, when enabled for a linked org, causes the Jira
Cloud `issue.updated` webhook handler to log the full webhook payload
plus a focused log line whenever the changelog contains a `project`
change. We need this data to design issue-link rewriting when a Jira
issue is moved between projects.

Resolves ISWF-1512

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.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.

2 participants