fix(export): improve error message when scope doesn't exist#10257
Open
davidfirst wants to merge 10 commits intomasterfrom
Open
fix(export): improve error message when scope doesn't exist#10257davidfirst wants to merge 10 commits intomasterfrom
davidfirst wants to merge 10 commits intomasterfrom
Conversation
…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".
Contributor
There was a problem hiding this comment.
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_KEYand tailor theScopeNotFoundOrDeniedmessage accordingly. - Introduce a
resolveRemote()wrapper aroundscopeRemotes.resolve()and route existing remote resolution call sites through it.
GiladShoham
approved these changes
Mar 26, 2026
auto-merge was automatically disabled
March 30, 2026 13:09
Pull Request is not mergeable
…t-found-error-message
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.
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` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 --allto undo the snap/tag, thenbit scope rename <old> <new>to fix the scope name.The original generic message is preserved for users who are not logged in.