Skip to content

Fix CLI not working with monorepos#273

Merged
sourya-deepsource merged 7 commits intomasterfrom
fix/monorepo-cli-resolution
Mar 25, 2026
Merged

Fix CLI not working with monorepos#273
sourya-deepsource merged 7 commits intomasterfrom
fix/monorepo-cli-resolution

Conversation

@jai-deepsource
Copy link
Contributor

@jai-deepsource jai-deepsource commented Mar 4, 2026

Summary

  • Auto-detect sub-repo path from CWD relative to git root and append it to the repo name sent to the API
  • Progressively strip path segments on 404 to find the matching sub-project
  • Show a friendly error when a monorepo is detected without --repo
  • Include analyzer name/shortcode in PR issues GraphQL response

Context

Plain ticket #6884175 — CLI commands fail with "Repository does not exist" when run inside a monorepo sub-directory. Now the CLI detects the relative path, converts / to :, and appends it as a sub-repo suffix.

Companion PR: DeepSourceCorp/asgard (same branch)

Test plan

  • Run deepsource issues from a monorepo sub-directory and verify auto-detection works
  • Run from root of a monorepo without --repo and verify friendly error
  • Verify PR issues include analyzer metadata

@deepsource-io
Copy link

deepsource-io bot commented Mar 4, 2026

DeepSource Code Review

We reviewed changes in f7f864d...10f28f1 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Mar 25, 2026 7:13p.m. Review ↗
Secrets Mar 25, 2026 7:13p.m. Review ↗
Test coverage Mar 25, 2026 7:13p.m. Review ↗

@shawnz-swiftly
Copy link

This also fixes #284

- Detect CWD relative to git root and append colon-delimited sub-repo
  suffix to the repo name sent to the API
- Progressively strip path segments on 404 to find the right sub-project
- Show friendly error when monorepo is detected without --repo
- Include analyzer name/shortcode in PR issues GraphQL response
- Make update check non-blocking by running it in a background goroutine
  and showing the result from the previous check instantly
- Break ApplyUpdate into PrepareUpdate/DownloadUpdate/VerifyUpdate/ExtractAndInstall
  with step-by-step progress output
- Extract monorepo retry logic into resolveIssuesWithRetry for clarity
- Use os.Getwd and filepath.Rel instead of shelling out to pwd
- Fix pointer receiver on CLIConfig.IsExpired and unused receiver in pat_login_flow
- When auto-branch detects a PR and the current run is still in progress,
  the fallback path was using GetPRIssues which returns empty results
  because PR-level issues aren't populated until the run completes
- Switch to GetRunIssuesFlat with the fallback commit OID in this case,
  matching what the non-PR fallback path already does
- Add regression test for the PR fallback scenario (#6884175)
@jai-deepsource jai-deepsource force-pushed the fix/monorepo-cli-resolution branch from b42dfdd to 5749e3e Compare March 23, 2026 20:11
- Fix retry loop skipping base-repo fallback when all path segments exhausted
- Guard against filepath.Rel returning "." which creates invalid repo suffix
- Rename blank receiver `_` to `lo` in PAT login flow
- Extract loadGoldenFile helper to reduce test complexity
- Convert startPATLoginFlow from method to standalone function (unused receiver)
- Add monorepo hint and repo-not-found error path tests for issues command
- Add PR issues query test covering node-to-Issue mapping and nil analyzer
- Add corrupt state file test for update ApplyUpdate error path
Display issue metadata (e.g. "JS-0116 · JavaScript") alongside each
issue title in the terminal output, making it easier to identify the
source analyzer at a glance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sourya-deepsource sourya-deepsource merged commit e04138f into master Mar 25, 2026
4 of 5 checks passed
@sourya-deepsource sourya-deepsource deleted the fix/monorepo-cli-resolution branch March 25, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants