Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: match on loginUrl/instanceUrl of ScratchOrgInfo if username does not match #1311

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

shetzel
Copy link
Contributor

@shetzel shetzel commented Jan 9, 2025

What does this PR do?

When running sf org display with a target-org that is not the scratch org admin user, the code would not match the ScratchOrgInfo SignupUser and would throw an error that the dev hub does not have a scratch org record with the provided org ID. The code now tries to match the ScratchOrgInfo.LoginUrl with the target-org's instanceUrl as an additional way to match. With this change, a user created within the scratch org can also have org details displayed when that user is the target-org username.

What issues does this PR fix or reference?

@W-17545444@

@cristiand391
Copy link
Member

QA notes:

setup:

  1. create scratch org
  2. create new user for it and generate password
  3. check sf org display works for user, log out
  4. re-auth using web login, confirm org display no longer works

✅ can find scratch info for new user
✅ UT covers scratch org with similar 15-char ID

❓ is the scratchAdminUsername field set somewhere in our code? I can't find any reference to it in sfdx-core/API objects:

salesforcecli:
https://github.com/search?q=org%3Asalesforcecli%20%2FscratchAdminUsername%2F&type=code
forcedotcom:
https://github.com/search?q=org%3Aforcedotcom%20%2FscratchAdminUsername%2F&type=code

ScratchOrgInfo:
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_scratchorginfo.htm?q=scratchAdminUsername

@cristiand391 cristiand391 merged commit 0a9c0f2 into main Jan 14, 2025
15 checks passed
@cristiand391 cristiand391 deleted the sh/enhanced-scratch-org-match branch January 14, 2025 13:45
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.

2 participants