Skip to content

refactor(project): replace --org flag with org/project positional#223

Merged
betegon merged 5 commits intomainfrom
refactor/project-view-org-positional
Feb 10, 2026
Merged

refactor(project): replace --org flag with org/project positional#223
betegon merged 5 commits intomainfrom
refactor/project-view-org-positional

Conversation

@betegon
Copy link
Member

@betegon betegon commented Feb 10, 2026

Summary

project view was the last command still using a --org flag. This replaces it with the <org>/<project> positional arg pattern that event view and issue view already use.

Changes

The command now accepts a single optional positional:

sentry project view                       # auto-detect from DSN or config
sentry project view <org>/<project>       # explicit org and project
sentry project view <project>             # find project across all orgs

For explicit and project-search cases, resolution is direct (single target). Auto-detect still goes through resolveAllTargets() so monorepo multi-project support is preserved.

Also cleaned up leftover --org/--project references in JSDoc comments across resolve-target.ts and resolve-issue.ts.

Test Plan

  • bun run typecheck passes
  • bun test test/e2e/project.test.ts — all 18 tests pass
  • bun test test/isolated/resolve-target.test.ts — all 27 tests pass
  • bun test test/lib/errors.test.ts — all tests pass

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 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 ✨

Cli

  • Add setup command for shell integration by BYK in #213
  • Add plural command aliases for list commands by betegon in #209

Other

  • (formatters) Display span duration in span tree by betegon in #219
  • (log) Add view command to display log entry details by betegon in #212
  • (repo) Add repo list command by betegon in #222
  • (setup) Auto-install Claude Code agent skill during setup by BYK in #216
  • (trace) Add trace list and view commands by betegon in #218

Bug Fixes 🐛

Upgrade

  • Handle EPERM in isProcessRunning for cross-user locks by BYK in #211
  • Replace curl pipe with direct binary download by BYK in #208

Other

  • (deps) Move runtime dependencies to devDependencies by BYK in #225

Documentation 📚

  • (log) Add documentation for sentry log view command by betegon in #214
  • Add documentation for log command by betegon in #210

Internal Changes 🔧

  • (ci) Remove merge-artifacts job with Craft 2.21.1 by BYK in #215
  • (project) Replace --org flag with org/project positional by betegon in #223
  • (setup) Unify binary placement via setup --install by BYK in #217
  • Enable minify for standalone binaries by BYK in #220

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

PR Preview Action v1.8.1

QR code for preview link

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

Built to branch gh-pages at 2026-02-10 20:27 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

Codecov Results 📊

✅ Patch coverage is 81.08%. Project has 3871 uncovered lines.
✅ Project coverage is 69.85%. Comparing base (base) to head (head).

Files with missing lines (67)
File Patch % Lines
human.ts 56.16% ⚠️ 395 Missing
resolve-target.ts 20.26% ⚠️ 366 Missing
list.ts 14.39% ⚠️ 345 Missing
api-client.ts 66.37% ⚠️ 230 Missing
list.ts 23.47% ⚠️ 212 Missing
oauth.ts 25.10% ⚠️ 194 Missing
list.ts 21.96% ⚠️ 167 Missing
plan.ts 19.37% ⚠️ 154 Missing
help.ts 19.85% ⚠️ 109 Missing
upgrade.ts 57.71% ⚠️ 107 Missing
view.ts 36.48% ⚠️ 101 Missing
interactive-login.ts 9.17% ⚠️ 99 Missing
view.ts 25.81% ⚠️ 92 Missing
view.ts 39.44% ⚠️ 86 Missing
clipboard.ts 4.49% ⚠️ 85 Missing
status.ts 24.07% ⚠️ 82 Missing
migration.ts 47.44% ⚠️ 82 Missing
list.ts 27.18% ⚠️ 75 Missing
browser.ts 4.11% ⚠️ 70 Missing
login.ts 33.33% ⚠️ 64 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
explain.ts 33.33% ⚠️ 56 Missing
telemetry.ts 79.86% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
upgrade.ts 66.91% ⚠️ 46 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
refresh.ts 40.63% ⚠️ 38 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
view.ts 87.27% ⚠️ 28 Missing
utils.ts 88.94% ⚠️ 25 Missing
view.ts 61.54% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
binary.ts 88.67% ⚠️ 17 Missing
list.ts 91.16% ⚠️ 16 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
help.ts 57.14% ⚠️ 15 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
logout.ts 56.00% ⚠️ 11 Missing
token.ts 52.17% ⚠️ 11 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
view.ts 94.70% ⚠️ 7 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.76% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
shell.ts 96.23% ⚠️ 6 Missing
app.ts 93.59% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
setup.ts 97.84% ⚠️ 4 Missing
list.ts 97.33% ⚠️ 4 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
output.ts 89.47% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
completions.ts 99.37% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 97.96% ⚠️ 1 Missing
trace.ts 99.16% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    68.84%    69.85%    +1.01%
==========================================
  Files          105       105         —
  Lines        12862     12841       -21
  Branches         0         0         —
==========================================
+ Hits          8854      8970      +116
- Misses        4008      3871      -137
- Partials         0         0         —

Generated by Codecov Action

@betegon betegon force-pushed the refactor/project-view-org-positional branch from 0ab2bf1 to 421ffa9 Compare February 10, 2026 15:54
@betegon betegon marked this pull request as ready for review February 10, 2026 15:55
project view now accepts <org>/<project> as a single positional argument
instead of separate --org flag and <project> positional, matching the
pattern used by event view and issue view. Auto-detect via DSN still
works when no argument is provided, including monorepo multi-target.
E2E tests now pass org/project as a single arg instead of --org flag.
Renamed test cases to reflect positional args instead of flags.
Deduplicate resolveFromProjectSearch() which was identically implemented
in event/view, trace/view, log/view, and project/view. The shared
resolveProjectBySlug() in resolve-target.ts handles project slug lookup
with consistent error messages and disambiguation prompts.
@betegon betegon force-pushed the refactor/project-view-org-positional branch from 421ffa9 to 9da8df4 Compare February 10, 2026 20:11
Comment on lines +249 to +259
case ProjectSpecificationType.Explicit:
// Direct org/project - single target, no multi-target resolution
resolvedTargets = [
{
org: parsed.org,
project: parsed.project,
orgDisplay: parsed.org,
projectDisplay: parsed.project,
},
];
break;
Copy link

Choose a reason for hiding this comment

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

Bug: The fetchProjectDetails function in project/view.ts incorrectly swallows ApiErrors (like 404s), returning null instead of propagating the error when a non-existent project is specified.
Severity: MEDIUM

Suggested Fix

Modify the catch block in the fetchProjectDetails function within project/view.ts. Instead of catching all errors and returning null, allow ApiError to be re-thrown, similar to how AuthError is handled. This will ensure that API errors like 404s are propagated up and displayed to the user, providing more specific feedback.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/commands/project/view.ts#L249-L259

Potential issue: In `project/view.ts`, the `fetchProjectDetails` function catches any
error except `AuthError` and returns `null`. When a user provides an explicit but
non-existent organization or project, the `getProject` call throws an `ApiError` (e.g.,
404 Not Found). This error is caught and converted to `null`, causing the command to
later fail with a generic `buildContextError()` because no projects were found. This
provides an unhelpful error message to the user instead of the specific API error, and
contradicts the command's E2E test expectations which check for "not found" or "404" in
the output.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member Author

Choose a reason for hiding this comment

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

intentional. this is a UX followup.

@betegon betegon merged commit 60544e3 into main Feb 10, 2026
24 checks passed
@betegon betegon deleted the refactor/project-view-org-positional branch February 10, 2026 20:40
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