Skip to content

feat(slack): Check Seer credits before running an agent chat mention - #129976

Merged
alexsohn1126 merged 0 commit into
alexsohn/cw-2325-slack-out-of-credits-repliesfrom
alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat
Nov 7, 2026
Merged

alexsohn1126 merged 0 commit into
alexsohn/cw-2325-slack-out-of-credits-repliesfrom
alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat

Conversation

@alexsohn1126

@alexsohn1126 alexsohn1126 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

This PR is stacked on #129975 (alexsohn/cw-2325-slack-out-of-credits-replies), which builds on #130271's shared out-of-credits notification. Review those first.

Today, when someone @mentions Seer in Slack, we start an agent run no matter how many Seer credits the org has left. If the org can't pay for it, the run fails partway through, or the user is left watching "is thinking..." with no explanation. A mention has no button we could have hidden ahead of time, so the only place to catch this is when the mention arrives.

Now, once the mention task knows who the user is and that they belong to the org, it checks whether the org can afford an agent chat message. If it can't, the task sends the shared out-of-credits notification, marked as "Seer never started", to that user as an ephemeral reply in the thread. It goes through the notification platform's Slack renderer, so it's the same message the autofix flow uses. The task then clears the thread's "is thinking..." status, records an out_of_seer_credits halt and returns. It skips everything else: reading the thread and linked messages, the inaccessible-links notice, and the agent run. If the reply fails to send, the status still gets cleared and no run starts.

The "is thinking..." status is set by the Slack webhook before the task is queued. I didn't move the credit check into the webhook, because that would put a billing call inside Slack's 3-second response window. So the status shows for a moment and then clears. Like the other halts in this task, the account-link and org-membership checks still run first, so an unlinked user gets the "link your account" prompt, not a credits message. While organizations:seer-credit-checks is off, the check always passes and nothing changes.

The shared message is the same whether or not Seer started, and its wording talks about continuing an Autofix run, which reads a bit off for a chat mention. If we want different copy here, it belongs in the shared notification, not this PR.

Fixes CW-2342

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

CW-2342

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 4, 2026
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat branch from c7f7efa to 6a3a696 Compare November 4, 2026 22:05
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2325-slack-out-of-credits-replies branch from 9e883a3 to b6b03b8 Compare November 5, 2026 21:01
@alexsohn1126
alexsohn1126 removed this pull request from stack #130118 November 5, 2026 21:01
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat branch from 6a3a696 to 2b13f99 Compare November 5, 2026 21:05
@alexsohn1126
alexsohn1126 removed this pull request from stack #130129 November 5, 2026 21:08
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2325-slack-out-of-credits-replies branch 2 times, most recently from 8df47e0 to 3920a4b Compare November 5, 2026 21:50
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat branch from 2b13f99 to bbc84c2 Compare November 5, 2026 21:53
@alexsohn1126
alexsohn1126 removed this pull request from stack #130131 November 6, 2026 22:28
@alexsohn1126
alexsohn1126 removed this pull request from stack #130325 November 7, 2026 03:50
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat branch from bbc84c2 to ff2979f Compare November 7, 2026 03:50
@alexsohn1126
alexsohn1126 merged commit ff2979f into alexsohn/cw-2325-slack-out-of-credits-replies Nov 7, 2026
@alexsohn1126
alexsohn1126 force-pushed the alexsohn/cw-2325-slack-out-of-credits-replies branch from 3920a4b to 893492f Compare November 7, 2026 03:50
@alexsohn1126
alexsohn1126 deleted the alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat branch November 7, 2026 03:50
@github-actions github-actions Bot removed the Scope: Backend Automatically applied to PRs that change backend components label Nov 7, 2026
@alexsohn1126
alexsohn1126 restored the alexsohn/cw-2342-slack-check-seer-credits-before-running-an-agent-chat branch November 7, 2026 03:51
@semgrep-code-getsentry

Copy link
Copy Markdown
Contributor

Semgrep found 1 ssc-850b2fbf-06b4-4cff-aa0b-66db70e2c786 finding:

  • static/app/utils/discover/eventView.spec.tsx

🟠 High severity issue identified in your code:

Risk: Affected versions of decode-uri-component are vulnerable to Inefficient Algorithmic Complexity / Uncontrolled Resource Consumption. decodeUriComponent() falls back to a custom decoder on malformed input that performs one full-string regex replacement per distinct percent-encoded run, giving quadratic time complexity. The function is reached directly, or indirectly through query-string (parse(), parseUrl(), stringifyUrl(), pick(), exclude()), which decodes every key and value with decode-uri-component. An attacker can send input with many distinct percent-encoded runs and a malformed sequence (e.g. a trailing "%zz") to block the Node.js event loop and cause a denial of service.

Fix: Upgrade this library to at least version 0.5.1 at sentry/pnpm-lock.yaml:5876.

Reference(s): https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-112471, GHSA-qr28-fpjm-wq7f, CVE-2026-118664

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.

1 participant