Skip to content

feat(tools): expose selected package versions for exact events - #1293

Merged
BYK merged 12 commits into
getsentry:mainfrom
mr-danya:trusst/sentry-mcp-pr-handoff
Nov 3, 2026
Merged

BYK merged 12 commits into
getsentry:mainfrom
mr-danya:trusst/sentry-mcp-pr-handoff

Conversation

@mr-danya

@mr-danya mr-danya commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds optional packageNames selection to exact-event reads through get_sentry_resource and get_issue_details, so dependency compatibility diagnosis can use versions recorded with the event. Returns up to 10 selected packages in structuredContent for supported event types in experimental mode, and in Markdown responses otherwise, with distinct states for unavailable metadata and unlisted packages and bounded version lengths. Calls without a selection retain their existing output, with no additional API requests.

Fixes #1292.

Before / After

Before: event packages → discarded during parsing → versions unavailable
After:  event packages → exact-name selection → structured or Markdown response

Retain event package metadata and support bounded exact-name selection
through the existing resource and issue readers. Include selected versions
with supplied Markdown and local formatting without extra API requests.

Fixes getsentry#1292

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
@mr-danya
mr-danya marked this pull request as ready for review September 8, 2026 01:46
mr-danya and others added 3 commits September 10, 2026 12:03
Merge upstream/main and retain package selection in the new structured
issue responses as well as Markdown fallback. Share selection logic and
cover both response formats through the tool and MCP boundaries.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
Preserve package-selection test imports alongside upstream tool failure
telemetry tests and the latest issue-details replay limits.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
Preserve selected event package versions alongside suspect commit output
and adapt package-selection fixtures to numeric issue event endpoints.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Sep 29, 2026
mr-danya and others added 2 commits October 6, 2026 13:30
Preserve package selection alongside updated resource telemetry and nullable
event context documentation.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
Preserve selected package versions with experimental structured issue details
and locally formatted event bodies. Regenerate definitions and update response
snapshots for the upstream formatting contract.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@mr-danya is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

BYK added a commit that referenced this pull request Oct 23, 2026
…me (#1607)

Two places where what the library SDK accepts doesn't match what
commands actually get:

- **Scalar values for variadic flags.** Stricli always passes variadic
flags to a handler as arrays, but the SDK forwards the caller's flags
as-is. An untyped caller passing `{ field: "title" }` to `explore`
crashed with `e.find is not a function`
([CLI-28C](https://sentry.sentry.io/issues/7602736942/),
[CLI-2B4](https://sentry.sentry.io/issues/7630797537/)).
getsentry/cli#1648 fixed the generated types. `applyFlagDefaults` now
also wraps scalar values in an array at runtime, so plain JS callers
work.
- **Streaming overloads.** The `AsyncIterable` overload for `log list
--follow` and `dashboard view --refresh` didn't accept trailing
positionals, so `sdk.log.list({ follow: "5" }, "org/project")` failed to
type-check even though the runtime accepts it.

This replaces three getsentry/cli PRs that patched `explore` directly.
#1293's `parse: (v: string[]) => v` was wrong because Stricli calls
`parse` once per value. #1218 and #1294 coerced the arrays inside
`explore`. The variadic fix here is at the SDK boundary, which is the
only path that can pass a scalar.

Ported from getsentry/cli#1218, getsentry/cli#1293, getsentry/cli#1294,
and the SDK part of getsentry/cli#1655. All are being closed with the
repo archive.

<!-- junior-request-attribution:start -->
via **BYK**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3Ad9c5b0de1ecf3c7114be7025 -->

--

[View Junior Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3Ad9c5b0de1ecf3c7114be7025/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <burak.kaya@sentry.io>
mr-danya and others added 3 commits November 2, 2026 06:21
Use a Map and Array.from for package selection, simplify package status
handling, and render status labels with a switch. Share the existing CLI
Markdown escape helper through toolkit-core and retain list-line normalization.

Preserve upstream formatter imports, attribution tests, and input-limit tests
while resolving the merge conflicts.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
Resolve the server test import conflict by keeping both createDefaultEvent
and eventFixture.

Co-Authored-By: Claude <noreply@anthropic.com>
Replace the hand-rolled escape chain for selected package versions with
code spans. Package names and versions are identifiers, and a code span
needs no Markdown, HTML, or pipe escaping. This drops the `&amp;`
rewriting and `\|` escaping, which only added noise in list items.

Move the two identical `formatInlineCode` copies in mcp-core into
`internal/inline-code.ts` and reuse it here. It now collapses line breaks,
matching how CommonMark renders code spans, so values stay on one line.

Revert the move of `escapeMarkdownInline` into toolkit-core. The CLI
helper is back where it was and MCP no longer depends on it.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@BYK
BYK enabled auto-merge (squash) November 2, 2026 12:13
BYK added a commit that referenced this pull request Nov 2, 2026
…#1795)

Adds `@sentry/toolkit-core/markdown`, one place for the CLI and MCP to
put upstream data into Markdown without hand-rolled escaping, and moves
MCP's issue and event output onto it (#1797, merged into this branch).
This is the first step of the plan that came out of the escaping review
on #1293.

The helper is picked by what the value is, not by which characters it
contains:

| helper | for | how |
|---|---|---|
| `inlineCode` | identifiers, slugs, queries, short values | fence
longer than any backtick run; padding keeps a leading/trailing backtick
or space; line breaks become spaces |
| `codeBlock` | messages, stack traces, JSON | fence (≥3) longer than
any backtick run, so no line of the value can close the block |
| `text` | values that should read as prose | backslash escapes only, no
runtime deps; line breaks become spaces |

The threat in MCP is structural: upstream text breaking out of its list
item or block and adding headings or sections, for example a fake `##
Response Notes`. Each helper keeps the value inside the line or block it
is placed in. `inlineCode` needs no escaping, so it is the default for
MCP output; models read the value unchanged.

**Same library as the CLI:** toolkit-core has no Markdown runtime
dependencies. `text` escapes CommonMark/GFM inline syntax, line-start
syntax (headings, lists, quotes, rules), and the `:`/`.`/`@` that would
start a literal autolink, so URLs, `www.` domains, and emails stay plain
text. It never writes character references, because `marked` keeps them
as-is in text tokens and the CLI would print `&#x77;`. `marked` moves to
the workspace catalog, so the CLI and toolkit-core's tests use the same
version.

**Property tests** parse each helper's output with both `marked` (the
CLI's parser) and micromark (CommonMark reference, with GFM), placed
mid-line and at the end of a list item, and check that any input
round-trips as the same literal value with no other structure. They pass
at 20,000 runs locally; CI runs 500.

**Consumers:** MCP's two `formatInlineCode` copies use `inlineCode`;
mcp-core's `formatting.ts` uses `codeBlock` for messages, exception
values, frames, and queries, `text` for titles and culprits, and
`inlineCode` for tag values. The CLI's `escapeMarkdownInline`,
`escapeMarkdownCell`, and `safeCodeSpan` are not swapped in this PR: the
CLI wants URLs in escaped text to stay clickable autolinks
(`renderOneInline` strips escapes inside them), while `text` blocks
autolinks on purpose, and the cell helpers need pipe handling that
`text` and `inlineCode` don't do. That move needs a table-cell helper
and an autolink decision, so it comes next.

**Dependencies:** `marked` (catalog), `mdast-util-from-markdown`,
`mdast-util-gfm`, and `micromark-extension-gfm` are toolkit-core dev
deps for the test oracles. The lockfile also moves `unist-util-visit`
from 5.0.0 to 5.1.0 as part of that resolution.

Docs: toolkit-core README section and a bullet in
`docs/contributing/tool-responses.md` under "Formatting Upstream Data".

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A67232d03908f6d80361e0c2c -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A67232d03908f6d80361e0c2c/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.com>
Preserve package selection alongside resource aliases and regenerate tool definitions. Align package-selection snapshots with upstream tag formatting.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
auto-merge was automatically disabled November 3, 2026 21:59

Head branch was pushed to by a user without write access

Comment on lines +82 to +83
export const ParamPackageNames = z
.array(z.string().min(1).max(256))

@semgrep-code-getsentry semgrep-code-getsentry Bot Nov 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High severity issue identified in your code:

Risk: Affected versions of zod are vulnerable to Allocation of Resources Without Limits or Throttling. Zod parses every element of an array, set or map schema and records one validation issue per invalid element, with no cap or early stop. Upper size bounds (.max(), .length(), .size(), or z.maxLength()/z.length()/z.maxSize()/z.size() checks) only ran after all elements had been parsed, so they did not limit the work. An attacker who submits a very large collection (e.g. a million invalid items for z.array(z.string().uuid())) forces the allocation of millions of issue objects, which can exhaust memory and crash the process. Upgrade to zod 4.6.6 or later, which rejects oversized input before parsing its elements when the schema has an upper bound, and add an upper bound (e.g. .max(n)) to every collection schema that parses untrusted input: unbounded schemas stay exposed even after the upgrade.

Fix: Upgrade this library to at least version 4.6.6 at toolkit/pnpm-lock.yaml:9619.

Reference(s): GHSA-mrhx-c7xc-m3w5, CVE-2023-54404

🍰 Fixed in commit d622ab8 🍰

Comment on lines +6 to +21
packages: z.array(
z.discriminatedUnion("status", [
z.object({
name: z.string(),
status: z.literal("recorded"),
version: z.string(),
truncated: z.boolean(),
}),
z.object({
name: z.string(),
status: z.enum(["not_listed", "version_not_recorded"]),
version: z.null(),
truncated: z.literal(false),
}),
]),
),

@semgrep-code-getsentry semgrep-code-getsentry Bot Nov 3, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High severity issue identified in your code:

Risk: Affected versions of zod are vulnerable to Allocation of Resources Without Limits or Throttling. Zod parses every element of an array, set or map schema and records one validation issue per invalid element, with no cap or early stop. Upper size bounds (.max(), .length(), .size(), or z.maxLength()/z.length()/z.maxSize()/z.size() checks) only ran after all elements had been parsed, so they did not limit the work. An attacker who submits a very large collection (e.g. a million invalid items for z.array(z.string().uuid())) forces the allocation of millions of issue objects, which can exhaust memory and crash the process. Upgrade to zod 4.6.6 or later, which rejects oversized input before parsing its elements when the schema has an upper bound, and add an upper bound (e.g. .max(n)) to every collection schema that parses untrusted input: unbounded schemas stay exposed even after the upgrade.

Fix: Upgrade this library to at least version 4.6.6 at toolkit/pnpm-lock.yaml:9619.

Reference(s): GHSA-mrhx-c7xc-m3w5, CVE-2023-54404

🍰 Fixed in commit d622ab8 🍰

…handoff

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
sentry-junior[bot]
sentry-junior Bot previously requested changes Nov 3, 2026

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this is well scoped. The packages schema matches the producer contract: Sentry serializes packages from the event's modules, and Relay normalizes that to Object<String>. Selection is bounded at the MCP boundary. Using a Map avoids prototype lookups, and calls without packageNames keep their existing output. The exact-event guards in both tools are consistent with the docs, and the tests cover the states well.

One thing to fix before this lands:

  • internal/inline-code.ts adds a second Markdown code-span helper (formatInlineCode) that duplicates inlineCode from @sentry/toolkit-core/markdown. formatting.ts already imports and uses that helper. The shared one also pads values that start or end with a space, which the new copy doesn't. Use inlineCode in formatEventPackages, then delete inline-code.ts and its test. Also update the formatInlineCode reference in docs/contributing/tool-responses.md. Two imports of the new helper are unused and look like merge leftovers: one in tool-helpers/ai-conversation-actions.ts and one in support/search-events/formatters.ts. Remove both.

FYI, I merged main into the branch to pick up the zod lockfile fix that the semgrep findings were about. Pull before you push again.

Remove the duplicate formatter and unused imports, update response documentation, and cover surrounding spaces in selected package names and versions.

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
@mr-danya

mr-danya commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in d2cd3f8. Package names and versions now use inlineCode from @sentry/toolkit-core/markdown. Removed the duplicate helper and its test, both unused imports, and updated the response documentation. Added a tool-level regression test for surrounding spaces; it failed with the old helper and passes with the shared one.

TypeScript, lint, generated definitions, all 2,013 MCP core tests, and synthetic CLI stdio checks for both readers in Markdown and JSON passed. The full local suite still has the two existing macOS environment failures in CLI tests (missing Xcode actool and the Linux/musl installer test).

@sentry-junior
sentry-junior Bot dismissed their stale review November 3, 2026 23:11

Addressed in d2cd3f8.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me now. d2cd3f8 switches package rendering to the shared inlineCode, removes the duplicate helper and both unused imports, and the new test pins the surrounding-space padding. mcp-core tsc and tests and repo-wide lint pass locally on this head.

@BYK
BYK enabled auto-merge (squash) November 3, 2026 23:13
@BYK
BYK merged commit 47cc01a into getsentry:main Nov 3, 2026
24 of 25 checks passed

This branch was successfully deployed

1 active deployment
Actions — d2cd3f87 Deployed Nov 3, 2026 by mr-danya via eval #1540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose installed package versions in exact-event MCP responses

2 participants