Skip to content

fix: 3 bug fixes — seer root cause extraction, release set-commits masking, issue selector hint#1023

Closed
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/sentry-cli-issues-5362
Closed

fix: 3 bug fixes — seer root cause extraction, release set-commits masking, issue selector hint#1023
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/sentry-cli-issues-5362

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 25, 2026

Overview

Three independent bug fixes, each in its own commit.


1. fix(seer): extractRootCauses empty causes array blocks agent artifact fallback

Root Cause: searchContainersForRootCauses() in src/types/seer.ts returned early when a legacy container had causes: [] (empty array), because [] is truthy in JavaScript. This prevented fallthrough to the agent artifact format (searchBlocksForAgentRootCause).

Trigger: Seer API returns a block with key: "root_cause_analysis" and causes: [] (legacy format, empty) alongside agent artifacts with key: "root_cause" and valid data. issue explain reports "no root causes found" even though agent data exists.

Fix: Added container.causes.length > 0 check so empty arrays fall through to the agent artifact format. Added regression test.

Related: #958


2. fix(release): set-commits default mode masks unrelated 400 errors as missing repo integration

Root Cause: setCommitsDefault() in src/commands/release/set-commits.ts caught any ApiError with status 400 from setCommitsAuto() and treated it as "no repository integration". However, setCommitsAuto() internally calls setCommitsWithRefs() which can return HTTP 400 for unrelated reasons (invalid commit refs, bad release state).

Trigger: Run sentry release set-commits <version> (default mode, no flags) when the repo integration exists but the refs are invalid. The real error is silently swallowed, a false 1-hour negative cache is created, and the command falls back to local git.

Fix: Narrowed the catch to only match the specific "No repository integrations" error message from setCommitsAuto's client-side check. Unrelated 400 errors now propagate to the user. Added two regression tests.


3. fix(issue): selector error hint suggests misleading is:resolved query

Root Cause: In resolveSelector() in src/commands/issue/utils.ts, when @latest/@most_frequent found no unresolved issues, the error hint directed users to sentry issue list <org>/ -q "is:resolved". This was misleading because the selectors only work on unresolved issues and listing resolved issues doesn't help find the issue the user wanted.

Trigger: Run sentry issue view @latest when the organization has no unresolved issues.

Fix: Changed the hint to sentry issue list <org>/ (no filter) so users see all available issues. Updated the corresponding test assertion.

Open in Web View Automation 

cursoragent and others added 3 commits May 25, 2026 12:11
… fallback

searchContainersForRootCauses returned early when container.causes
was an empty array ([]) because [] is truthy in JavaScript. This
prevented fallthrough to the agent artifact format
(searchBlocksForAgentRootCause), causing 'no root causes found'
errors when the API returned empty legacy causes alongside valid
agent root_cause artifacts.

Added length check so empty arrays fall through to agent format.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
…missing repo integration

setCommitsDefault() caught any ApiError with status 400 from
setCommitsAuto() and treated it as 'no repository integration'.
However, setCommitsAuto() internally calls setCommitsWithRefs()
which can also return HTTP 400 for unrelated reasons (invalid
commit refs, bad release state, etc.). This caused:
1. A false 1-hour negative cache (cacheNoRepoIntegration)
2. Silent fallback to local git history
3. The real API error being hidden from the user

Narrowed the catch to only match the specific 'No repository
integrations' error message from setCommitsAuto's own check.
Unrelated 400 errors now propagate to the user.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
When @latest or @most_frequent found no unresolved issues, the
ResolutionError hint directed users to 'sentry issue list <org>/
-q "is:resolved"'. This was misleading because:
1. The selectors only work on unresolved issues
2. Listing resolved issues doesn't help find the issue they wanted
3. The suggested command can't be combined with the selector

Changed the hint to 'sentry issue list <org>/' (no filter) so
users see all available issues and can determine what to do next.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1023/

Built to branch gh-pages at 2026-05-25 12:18 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 4275 uncovered lines.


Generated by Codecov Action

@BYK
Copy link
Copy Markdown
Member

BYK commented Jun 3, 2026

Superseded by #1051, which consolidates the genuinely-needed, de-duplicated fixes from this PR (rebased onto current main) along with the others. Closing in favor of #1051.

@BYK BYK closed this Jun 3, 2026
BYK added a commit that referenced this pull request Jun 3, 2026
…1051)

## Summary

Consolidates the five open Cursor BugBot PRs (#908, #947, #973, #1023,
#1044)
into a single, de-duplicated, rebased PR. Each genuinely-needed fix is
verified
against current `main`; overlapping fixes use the best variant; stale
and
subjective changes are dropped.

## Why consolidate

The five BugBot PRs heavily overlapped and had gone stale (7–113 commits
behind
`main`): the cache `JSON.parse` guard appeared 3×, the `withTTY` test
fix 2×, the
pagination guard 3×. Several also failed CI only on unrelated base
drift. This PR
lands the real fixes once and adds guardrails so the
duplication/staleness
doesn't recur.

## Fixes included

**Cache hardening** (`fix(db)`) — from #908/#947/#1044
- New `safeParseJson()` db helper; used in `getPaginationState()` (with
`Array.isArray` validation) and `getCachedDetection()` so corrupt cached
JSON
  is a cache miss, not a crash.
- `log.debug()` added to three silent catch blocks in
`sentry-client.ts`.

**Event pagination** (`fix(events)`) — from #947
- `listIssueEvents` now uses the shared `autoPaginate()` helper and
drops
`nextCursor` when a page overshoots `limit`, so `-c next` never skips
events.
Adds a property test for the `autoPaginate` trim-drops-cursor invariant
plus a
  focused overshoot regression test.

**Relative time** (`fix(formatters)`) — from #1044
- `formatRelativeTime` clamps `diffMs` to `>= 0` ("0m ago" instead of
"-5m ago").

**Seer** (`fix(seer)`) — from #973/#1023, relates to #958
- `normalizeAgentStatus` maps `canceled`/`cancelled` → `CANCELLED`
(fixes a
polling-timeout bug) and `need_more_information` →
`NEED_MORE_INFORMATION`.
- `searchContainersForRootCauses` requires `causes.length > 0` so an
empty
  legacy array no longer blocks the agent-artifact fallthrough.
- `extractNoSolutionReason` reads the step-level `description` (current
API)
  before the artifact-level `reason` (legacy).

**Release set-commits** (`fix(release)`) — from #1023
- Narrow the default-mode 400 fallback to the exact
`NO_REPO_INTEGRATIONS_MESSAGE`
so unrelated 400s (invalid refs, bad release state) propagate instead of
being
  masked as "no integration".

**Test isolation** (`test`) — from #1044/#947
- `withTTY` now saves/restores `NO_COLOR` and `FORCE_COLOR` (CI sets
`NO_COLOR=1`).

## Systemic guardrails

- `script/check-error-patterns.ts` gains an advisory silent-catch scan
  (`SENTRY_STRICT_SILENT_CATCH=1` to enforce).
- `AGENTS.md` documents automated-fix-PR rules: check existing
PRs/issues first,
rebase before review, separate correctness from opinion, prefer shared
helpers.
- Removed a stale, now-unused `biome-ignore` in `formatters/local.ts`
that broke
  repo-wide lint under biome 2.3.8.

## Dropped (intentionally)

- **`issue list` "lifetime" collapse removal** (#973) — superseded on
`main` by
  the `shouldCollapseLifetime` param; issue #969 is already closed.
- **Issue selector hint `is:resolved` → bare list** (#1023) — subjective
UX;
  `main`'s current behavior is deliberate.

## Follow-up

- A scheduled stale-bot to auto-close inactive bot PRs (out of scope
here).

## Testing

- `pnpm run typecheck` ✓
- `pnpm run lint` ✓ (766 files)
- `pnpm run check:errors` ✓ · `pnpm run check:deps` ✓
- `pnpm run test:unit` ✓ (325 files, 7419 passed, 13 skipped)

Closes #908, #947, #973, #1023, #1044.
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