Closed SCWells72 closed 3 weeks ago
Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.
"orgN"... is not valid JSON
do you have orgName
set in config/namespace-scratch-def.json
? can you check if it's valid JSON (jq config/namespace-scratch-def.json
)?
I tried on sf v2.46.5 (current nightly) and can't repro using this scratch definition file:
{
"orgName": "Dreamhouse",
"edition": "Developer",
"namespace": "cristiand391",
"features": ["Walkthroughs", "EnableSetPasswordInApi"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"mobileSettings": {
"enableS1EncryptedStoragePref2": false
}
}
}
@cristiand391, here are the exact contents of config/namespace-scratch-def.json
:
{
"orgName": "external_services_ns",
"edition": "Developer",
"hasSampleData": false,
"features": [
"EnableSetPasswordInApi"
],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"mobileSettings": {
"enableS1EncryptedStoragePref2": false
}
}
}
Note that I also tried adding "namespace": "<namespace>"
to that file and it fails in the same manner.
Let me know if I can provide anything else.
@SCWells72 I tried installing the same node and sf versions but I can't repro on macos, I'll give it a try on windows tomorrow and report back.
FWIW, I don't see any recent change in JSON.parse
in node, the error you get says you have a wrong JSON (from your examples it seems it's config/namespace-scratch-def.json
). If you can, passing --dev-debug
should make it print the stacktrace where the JSON parsing is failing.
@cristiand391, here you go:
*** Internal Diagnostic ***
SyntaxError: Unexpected token '', "{
"orgN"... is not valid JSON
at JSON.parse (<anonymous>)
at buildScratchOrgRequest (file:///C:/Users/Scott/AppData/Local/sf/client/2.44.8-c60512e/node_modules/@salesforce/plugin-org/lib/shared/scratchOrgRequest.js:16:20)
at async EnvCreateScratch.run (file:///C:/Users/Scott/AppData/Local/sf/client/2.44.8-c60512e/node_modules/@salesforce/plugin-org/lib/commands/org/create/scratch.js:152:38)
at async EnvCreateScratch._run (C:\Users\Scott\AppData\Local\sf\client\2.44.8-c60512e\node_modules\@oclif\core\lib\command.js:311:22)
at async Config.runCommand (C:\Users\Scott\AppData\Local\sf\client\2.44.8-c60512e\node_modules\@oclif\core\lib\config\config.js:433:25)
at async run (C:\Users\Scott\AppData\Local\sf\client\2.44.8-c60512e\node_modules\@oclif\core\lib\main.js:92:16)
******
it's reading your config/namespace-scratch-def.json
here:
that says your file isn't valid JSON.
If you can validate your JSON and still repro then the only thing I can think of is some of the changes done to JSON.parse in node v20 (can't find them in node's changelog). It broke some of our tests a while ago but it was updates to the error handler: https://github.com/forcedotcom/kit/pull/236
I can't repro on windows.
@cristiand391, here's the exact file that's resulting in the error:
It's showing up as valid in IntelliJ IDEA, VS Code, etc. Are you able to use it to create a scratch org? Well, I assume it'll fail because you don't have access to that namespace -- and editing the file will obviously risk changing it -- but hopefully you'll know quickly whether or not it gets past the specific error that I'm seeing.
That file begins with a BOM (U+FEFF char) and the code reads the file as UTF-8 so it's interpreting it as a non-JSON parseable character. I would try to regenerate that file or look into how it's being generated.
Wow...that's bizarre. That file was literally copied directly from the existing project-scratch-def.json
file which works just fine. I wonder what added that BOM to its start. I also wonder why neither dev tool actually designated that as a potential problem, though to be fair, IntelliJ IDEA did show that as a characteristic of the file encoding when I knew to check there:
Anyway, obviously it works fine now. Strange that nothing actually identified that as a potential problem, though...
Thanks for taking the time to help troubleshoot, and glad to hear it was user error and not a real problem!
I'm glad we got this figured out! Thanks for sharing the file.
Summary
When trying to create a scratch org with a namespace, I get an error:
Here's the
sfdx-project.json
:Note that
<namespace>
is a namespace that has already been registered with<devHubAlias>
, and I've successfully created scratch orgs with that namespace in the past. This seems to be a recent regression.System Information
Happens in both
cmd.exe
andbash
. Here's the version info: