Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

improve(issue-list): fix PR #312 review concerns - #315

Closed
BYK wants to merge 9 commits into
mainfrom
improve-pr-312
Closed

BYK wants to merge 9 commits into
mainfrom
improve-pr-312

Conversation

@BYK

@BYK BYK commented Mar 2, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up improvements identified during review of #312 (fix/issue-list-project-id):

  • toNumericId correctness: Changed from Number(id) || undefined (falsy check) to explicit Number.isInteger(n) && n > 0 — toNumericId(0) was silently returning undefined even though 0 is technically a number. Sentry IDs are always positive integers so this is the correct semantic. Accepts null explicitly now (no more as unknown cast needed in tests).

  • Remove dead code from shared resolve functions: fetchProjectId was added to resolveAllTargets and resolveOrgAndProject but is only used by issue list. Removed it from those shared paths — it was adding unnecessary network calls to every command that uses these helpers (project list, org list, etc.) with no benefit.

  • Enrich auto-detect targets in issue list: The env-var/config-default path through resolveAllTargets now gets project IDs enriched in the issue list command itself via getProject, with a silent fallback to slug-based querying on any failure. This keeps enrichment scoped to where it's needed.

  • Fix unmocked fetch warning in test: The --cursor is accepted in multi-target mode test was hitting the preload fetch mock 3 times (3 retries) because it passed an explicit test-org/test-project target which triggered fetchProjectId → getProject without a network mock. Fixed by spying on apiClient.getProject.

betegon and others added 9 commits March 2, 2026 10:53
Store the numeric project ID alongside the slug in the cache so
downstream API calls can use the `project` query param instead of
`project:<slug>` search syntax.

Bump schema version to 7 with migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`sentry issue list sentry/sentry` failed because `project:slug` in the
search query only works for "actively selected" projects. When we have
the numeric project ID, use the `project` query param (Array<number>)
instead, which selects the project directly.

- Add `projectId` to `ResolvedTarget` and populate it from all
  resolution paths (explicit, DSN, cache, directory inference)
- `listIssuesPaginated` uses `project: [id]` query param when available,
  falls back to `project:slug` search syntax otherwise
- Thread `projectId` through `listIssuesAllPages` and `fetchIssuesForTarget`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that when projectId is provided, the `project` query param is
used and `project:slug` is omitted from the search query.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…warnings

- Replace nested ternary with if-statement in listIssuesPaginated
- Extract fetchProjectId helper to reduce resolveAllTargets complexity
- Use numeric separators (12_345) in test literals

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…projects

fetchProjectId previously swallowed all errors silently, causing
confusing downstream API errors when users typed a wrong project slug
or lacked permissions. Now throws ResolutionError on 404 and re-throws
AuthError, while still returning undefined for transient failures.

Partial-failure messages now name the specific projects that failed
(e.g. "Failed to fetch issues from org/proj-a") instead of just
showing a count, both in human-readable stderr and JSON error output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The pattern `Number(x.id) || undefined` appeared 7 times and
`cached.projectId ? Number(cached.projectId) : undefined` appeared
3 times across resolve-target.ts and list.ts. Extract a shared
`toNumericId` helper to replace all 10 occurrences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix 10 lint errors (trailing commas, line length, import ordering,
Response.json) and 2 test failures caused by fetchProjectId requiring
auth/region mocks when CLI flags are passed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…re project field

Improve patch coverage for PR #312 by adding tests for new functions
and enhancing existing assertions on error output format.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- toNumericId: accept null, use Number.isInteger + n > 0 (was falsy-check)
- Remove fetchProjectId from resolveAllTargets/resolveOrgAndProject shared
  paths (dead code that added network calls to non-issue-list commands)
- Enrich env-var/config-default auto-detect targets in issue list using
  getProject directly with silent fallback to slug-based querying
- Fix test: spy on getProject in cursor-accepted test to avoid hitting
  the preload fetch mock (removed 3 [TEST] Unexpected fetch call warnings)
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (formatters) Render all terminal output as markdown by BYK in #297
  • (issue-list) Global limit with fair distribution, compound cursor, and richer progress by BYK in #306

Bug Fixes 🐛

Api

  • Use limit param for issues endpoint page size by BYK in #309
  • Auto-correct ':' to '=' in --field values with a warning by BYK in #302

Formatters

  • Expand streaming table to fill terminal width by betegon in #314
  • Fix HTML entities and escaped underscores in table output by betegon in #313

Other

  • (ci) Generate JUnit XML to silence codecov-action warnings by BYK in #300
  • (nightly) Push to GHCR from artifacts dir so layer titles are bare filenames by BYK in #301
  • (test) Handle 0/-0 in getComparator anti-symmetry property test by BYK in #308

Internal Changes 🔧

  • (api) Wire listIssuesPaginated through @sentry/api SDK for type safety by BYK in #310

Other


🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ 2289 passed | Total: 2289 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +17
Passed Tests 📈 +17
Failed Tests —
Skipped Tests —

All tests are passing successfully.

✅ Patch coverage is 83.51%. Project has 3240 uncovered lines.
✅ Project coverage is 80.14%. Comparing base (base) to head (head).

Files with missing lines (4)
File Patch % Lines
resolve-target.ts 53.44% ⚠️ 291 Missing
api-client.ts 72.96% ⚠️ 242 Missing
list.ts 87.27% ⚠️ 95 Missing
schema.ts 93.07% ⚠️ 33 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    80.08%    80.14%    +0.06%
==========================================
  Files          120       120         —
  Lines        16232     16316       +84
  Branches         0         0         —
==========================================
+ Hits         12999     13076       +77
- Misses        3233      3240        +7
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK closed this Mar 2, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

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


expect(fetchProjectId("test-org", "test-project")).rejects.toThrow(
ResolutionError
);

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.

Missing await on rejects.toThrow makes assertions no-ops

Medium Severity

Both expect(fetchProjectId(...)).rejects.toThrow(...) calls are missing await. Without it, the returned promise is never awaited, so the assertion never actually runs — the test passes regardless of whether fetchProjectId throws or not. Every other rejects.toThrow usage in the test suite correctly uses await expect(...).

Additional Locations (1)

Fix in Cursor Fix in Web

@BYK
BYK deleted the improve-pr-312 branch March 20, 2026 19:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants