Closed AllanOricil closed 1 year ago
Hi @AllanOricil thanks for reporting this! How did you connect to your friend's scratch org? The org picker in VS Code will only display scratch orgs associated with your default dev hub. To use a scratch org you didn't create (and see the push/pull commands), you'll need to log into the dev hub associated with that scratch org and set that as your default dev hub. To authorize the new dev hub, use the org picker in the bottom toolbar. Let me know if you have any questions!
Hi @AllanOricil thanks for reporting this! How did you connect to your friend's scratch org? The org picker in VS Code will only display scratch orgs associated with your default dev hub. To use a scratch org you didn't create (and see the push/pull commands), you'll need to log into the dev hub associated with that scratch org and set that as your default dev hub. To authorize the new dev hub, use the org picker in the bottom toolbar. Let me know if you have any questions!
I authorized her Scratch Org on my sfdx using the credentials she generated on her side. I noticed I can do a source push command without any problems using the cli. Is just the VSCode Extension that does not allow me to do so. Also, the extension shows her SO set as my default one, so the extension knows her Scratch Org. It is just that it can't perform the push command with it.
Vscode extension knows about her Scratch Org
Scratch Org is connected but does not show as one of mine
Couple of pushes I did through the sfdx cli to her Scratch Org
I think you just need to enable all Scratch Orgs to use the Push Command extension and not just the ones I created. Maybe you are getting the list of SO from the ones created by the user and not all the SO available.
With her SO selected, the Push command from the extension does not show up
With my SO selected, even if it is expired, I can do a Push Command.
Hi @AllanOricil we tried to reproduce your issue by creating a scratch org, switching to a different dev hub (user), then setting the default org to the unrelated scratch org using the CLI, and we actually did see the Push
and Pull
commands in VS Code. Could you share the contents of your sfdx-config.json
file when you're connected to your friend's scratch org?
It looks like you're on the latest version of the CLI, could you also tell us which version of the Salesforce Extensions you're using?
Hi @AllanOricil we tried to reproduce your issue by creating a scratch org, switching to a different dev hub (user), then setting the default org to the unrelated scratch org using the CLI, and we actually did see the
Push
andPull
commands in VS Code. Could you share the contents of yoursfdx-config.json
file when you're connected to your friend's scratch org? It looks like you're on the latest version of the CLI, could you also tell us which version of the Salesforce Extensions you're using?
OBS: All the pictures below are displaying the computer time to help you see that I'm doing the tests right.
@AnanyaJha In the picture below you can see my sfdx and vscode extension versions.
I just switched to her Scratch Org and the sfdx-config.json
changed its content too. The Vscode extension also indicates this change in the button on the status bar (blue bar on the bottom).
But the Push command doesn't show up.
Now I changed to my Expired Scratch Org, to show that when the Scratch Org is mine the command appears, even when the SO is expired.
And I can see the Push command
Thanks @AllanOricil! Can you also post the output to sfdx force:config:get defaultdevhubusername
?
Thanks @AllanOricil! Can you also post the output to
sfdx force:config:get defaultdevhubusername
?
@AnanyaJha dont consider that weird error message after updating sfdx cli. That will be another bug I will open haha I also took the opportunity to update my vscode extension to the latest and the error is still there.
Hi @AllanOricil we're still working on reproducing this issue- can you confirm how you logged into your friend's org? We tried the following process:
After this process, she does not see the Push/Pull commands in VS Code nor the CLI. Is this the same process you used for your friend's scratch org? cc @sfsholden
Hi @AllanOricil we're still working on reproducing this issue- can you confirm how you logged into your friend's org? We tried the following process:
- I created a scratch org and created a scratch org user for my friend to use
- Went into the scratch org and changed the email address so she was able to generate a password for her scratch org user
- She changed the password and auth'd into the scratch org user with the custom login url that was generated when i created a scratch org user
After this process, she does not see the Push/Pull commands in VS Code nor the CLI. Is this the same process you used for your friend's scratch org? cc @sfsholden
@AnanyaJha
My friend and I are using the same devhuborg. She is connected to this devhub with her user and I with mine.
She created one Scratch Org, then generated the username and password using the CLI sfdx force:user:password:generate -u HER_SCRATCH_ORG_USERNAME
Then she gave the password and username to me.
From inside that sfdx project on the images I posted here, I ran sfdx force:auth:web:login
but using the VSCode Extension Command, instead of typing the command.
Vscode Opened the browser and I entered the credentials she gave to me.
The authentication worked without a problem and her Scratch Org was now registered on my SFDX.
I connected to her Scratch Org because I needed to push some code changes I did in that sfdx project. After connecting I tried to run the Vscode Extension Push Command and I noticed it was not showing up. Then I had to typesfdx force:source:push -u nina_so_2 -f
on the terminal to push everything and it worked! And this was the moment I understood something weird was happening.
@AnanyaJha
I think I discovered the issue. Her scratch org was registered as a "nonScratchOrg". But as I told before, I can run sfdx force:source:push
without any problem and It is a Scratch Org! Maybe the VScode Extension is using the list of "nonScratchOrgs" to determine if it should or not show the Push command, which in this case shown below would break this logic. What do you think?
Obs 1: I deleted some information in the output below for protection. Obs 2: I registered this SO using the VSCOde Extension Command.
Hi @AllanOricil thanks for all the info! We attempted to reproduce the issue by going through the same steps you mentioned above (creating two dev hub users & using the generated scratch org pwd to log in from the second dev hub user), but we are correctly seeing the Push/Pull
commands in VS Code. It seems like the issue may be with the specific scratch org you're attempting to use. Which auth file is the screenshot from, where are you seeing the nonScratchOrgs
section?
We aren't using the nonScratchOrgs
attribute when determining whether an org is scratch org; we check for the presence of a devhubUsername
attribute in the auth info for the scratch org. If there is an associated devhubUsername
, then it's a scratch org and the Push/Pull
commands will be displayed. In the .sfdx
folder in your home directory, open up the auth file associated with the scratch org you're working with. There should be a field for devhubUsername
as such:
you
@AnanyaJha This is the content of that file you asked. I just changed the accessToken and refreshToken to use a random, non usable, code.
{
"orgId": "00D3D0000003PlcUAE",
"accessToken": "9a0511de65229e046fe77493276e553196c40d6a7a7c5e123d027b40775f4764c695400d8982b1a7b5fd7eb7a2f3ed:65015ddc94997cff9a602499d8da5bdd",
"refreshToken": "555ff975fb1850dc6695d3f:ce46366f0d67d600493e17b2e8fa6053",
"instanceUrl": "https://page-dream-9422-dev-ed.cs70.my.salesforce.com",
"loginUrl": "https://test.salesforce.com/",
"username": "test-eizjxrgpwekh@example.com",
"clientId": "PlatformCLI",
"isDevHub": false
}
You can confirm that the credentials above are for the right SO in the images below.
@AllanOricil Thanks! Can you try adding in this line to the auth file for the scratch org "devHubUsername": "yourdevhubusername"
? When you authorize a new scratch org, the CLI should be adding in a devHubUsername
field to indicate what dev hub the scratch org is associated with. Ideally, reauthorizing should fix the problem but we can try manually adding the needed data too.
@AnanyaJha it worked. Here is what I did:
1 - Manually added a REAL devhubusername to the devHubUsername prop in that file, as shown below:
{
"orgId": "00D3D0000003PlcUAE",
"accessToken": "9a0511de65229e046f3dad049d8da5bdd",
"refreshToken": "555ff975fb1850dc6f96ece3cdfb020bc7695d3f:ce46366f0d67d600493e17b2e8fa6053",
"instanceUrl": "https://page-dream-9422-dev-ed.cs70.my.salesforce.com",
"loginUrl": "https://test.salesforce.com/",
"username": "test-eizjxrgpwekh@example.com",
"clientId": "PlatformCLI",
"devHubUsername": "allan.oricil@hpe.com",
"isDevHub": false
}
2 - After that I tried to find the push command and it was still not showing up 3 - Closed and Opened VSCode in the same Workspace and this time the command was appearing. This is probably because the files are read during the Activation of the extension. Maybe you can change it to read those files when they change in the .sfdx with a file listener. This way the user does not need to close and open the project again.
I also added a random string on the devHubUsername
prop and the command also appeared. After editing the file with the random string I closed and opened VSCode again to make sure the changes were picked up. So this devhubusername seems to be just used to show the push command, and it actually can be anything. Does it make sense? Maybe there is another way to control this.
{
"orgId": "00D3D0000003PlcUAE",
"accessToken": "9a0511de65229e046f3dad049d8da5bdd",
"refreshToken": "555ff975fb1850dc6f96ece3cdfb020bc7695d3f:ce46366f0d67d600493e17b2e8fa6053",
"instanceUrl": "https://page-dream-9422-dev-ed.cs70.my.salesforce.com",
"loginUrl": "https://test.salesforce.com/",
"username": "test-eizjxrgpwekh@example.com",
"clientId": "PlatformCLI",
"devHubUsername": "blabla",
"isDevHub": false
}
I authorized a new Scratch Org created by my colleague using the VSCode Extension and the same problem happened again. The auth file inside ./sfdx
does not have the devHubUsername again. Here is the Channel output showing the command vscode executed:
Hi @AllanOricil okay so it looks like the issue here is that the CLI does not reliably add the devhubusername attribute when you log in using a user on the dev hub and the generate password/key for the scratch org. I can log a new bug to look into whether the CLI should be adding in the devhubusername attribute in this scenario or whether there's a different attribute we can use to reliably detect a scratch org. As we discussed earlier, the workaround for now is to manually add in the devhubusername attribute. Thanks for reporting this!
This issue has been linked to a new work item: W-8515293
Hi @AllanOricil okay so it looks like the issue here is that the CLI does not reliably add the devhubusername attribute when you log in using a user on the dev hub and the generate password/key for the scratch org. I can log a new bug to look into whether the CLI should be adding in the devhubusername attribute in this scenario or whether there's a different attribute we can use to reliably detect a scratch org. As we discussed earlier, the workaround for now is to manually add in the devhubusername attribute. Thanks for reporting this!
@AnanyaJha Thank you for your response
This bug should be a top priority only because I hit it today and it's a minor inconvenience!
sfdx force:source:push
works as expected.
Summary
I have a friend's Scratch Org (SO) connected on my sfdx and when I set it as the default one VSCode does not show the Push Command. But when I switch back to one that I created the push command appears.
Steps To Reproduce:
Expected result
The vscode SFDX Push command should appear whenever you have a SO selected as the default and when you are inside an sfdx project.
Actual result
The Vscode SFDX Push command does not show for SO that the user did not create, even when it is authenticated and known by sfdx.
Additional information
VS Code Version:
SFDX CLI Version: sfdx-cli/7.78.1-5a65d9dd2f win32-x64 node-v12.18.3
OS and version: Windows 10