Skip to content

fix(export): improve error message when scope doesn't exist#10257

Open
davidfirst wants to merge 10 commits intomasterfrom
fix/export-scope-not-found-error-message
Open

fix(export): improve error message when scope doesn't exist#10257
davidfirst wants to merge 10 commits intomasterfrom
fix/export-scope-not-found-error-message

Conversation

@davidfirst
Copy link
Copy Markdown
Member

When exporting to a non-existent scope while already logged in, the error message was misleading — it suggested running bit login. Now it explains the scope may not exist or the user lacks access, and provides actionable recovery steps: bit reset --all to undo the snap/tag, then bit scope rename <old> <new> to fix the scope name.

The original generic message is preserved for users who are not logged in.

…ccessible

When exporting to a non-existent scope while logged in, the error previously
suggested running "bit login", which is misleading. Now it explains the scope
may not exist or the user lacks access, and provides recovery steps using
"bit reset --all" and "bit scope rename".
Copilot AI review requested due to automatic review settings March 26, 2026 17:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the export UX by providing a more accurate, actionable error message when exporting to a scope that doesn’t exist (or is access-denied) for users who appear to be logged in, while preserving the existing generic message for logged-out users.

Changes:

  • Detect “logged in” state via presence of CFG_USER_TOKEN_KEY and tailor the ScopeNotFoundOrDenied message accordingly.
  • Introduce a resolveRemote() wrapper around scopeRemotes.resolve() and route existing remote resolution call sites through it.

Comment thread scopes/scope/export/export.main.runtime.ts
Copilot AI review requested due to automatic review settings March 26, 2026 19:59
@davidfirst davidfirst enabled auto-merge (squash) March 26, 2026 19:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread scopes/scope/export/export.main.runtime.ts
auto-merge was automatically disabled March 30, 2026 13:09

Pull Request is not mergeable

Copilot AI review requested due to automatic review settings April 15, 2026 16:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings April 15, 2026 17:53
@davidfirst davidfirst enabled auto-merge (squash) April 15, 2026 17:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread scopes/scope/export/export.main.runtime.ts
Comment thread scopes/scope/export/export.main.runtime.ts
davidfirst added a commit that referenced this pull request Apr 15, 2026
…ompt (#10300)

Follow-up to #10297. The new \`isStaleCiRun\` helper runs \`git fetch
origin\` inside the hash-mismatch retry path. In the \`bit_pr\` CircleCI
job, \`origin\` is the default SSH remote and GitHub's host key isn't
seeded in \`known_hosts\` for that job's shell — so the fetch hits an
interactive "yes/no" host-key prompt and hangs the job until the
50-minute step timeout (seen on #10257). The \`bit_merge\` job avoids
this only because it rewrites \`origin\` to an HTTPS+token URL via
\`update_ssh_agent\`; \`bit_pr\` does not.

\`isStaleCiRun\` was added during PR review to guard a hypothetical
race: an older CI run finishing later could delete a newer run's lane
and re-export stale snaps. In practice that race is unlikely,
self-correcting (the next CI run on the latest commit publishes the
correct lane), and only affects a PR lane — not main. Removing the guard
restores the original simple retry from #10297, which is enough.
Copilot AI review requested due to automatic review settings April 16, 2026 13:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +306 to +313
} catch (err) {
if (err instanceof ScopeNotFoundOrDenied && getConfig(CFG_USER_TOKEN_KEY)) {
throw new BitError(
`unable to export to the remote scope "${scopeName}". the scope may not exist, or you don't have access to it.
if the scope name is wrong and you've already snapped/tagged, run "bit reset --all" to undo, then run "bit scope rename ${scopeName} <new-scope>" and snap/tag again`
);
}
throw err;
if (err instanceof ScopeNotFoundOrDenied && getConfig(CFG_USER_TOKEN_KEY)) {
throw new BitError(
`unable to export to the remote scope "${scopeName}". the scope may not exist, or you don't have access to it.
if the scope name is wrong and you've already snapped/tagged, run "bit reset --all" to undo, then run "bit scope rename ${scopeName} <new-scope>" and snap/tag again`
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.

3 participants