You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MDAPI REST Deploy - Unexpected token < in JSON at position -- incorrect exit code #860
Deploying to a fresh scratch org using the REST Metadata API sometimes results in deployment errors, often ~15-30 minutes after org creation, it works until it doesn't. Those errors aren't handled well and the result ended in "success" exit code (0) when it should be error (1+).
Errors in parsing a JSON message that is actually an HTML message causes everything to break and not handle the error correctly. SyntaxError: Unexpected token < in JSON at position 1
(The REST API crashing soon after creation I will be opening a support case for, this is specifically about the DX failings)
I have an example repository and the README has steps to run a script that creates an org, sets it to deploy via REST, then deploys until it breaks. It doesn't break 100% of the time but I'm probably seeing ~70+% failure rates, though each run could take 30+ minutes to test before giving up on it.
Expected result
Edge cases should be handled properly and when SFDX crashes it should result in a non-zero exit code.
Actual result
SFDX crashes out and prints to the STDERR channel but returns an exit code of 0 reporting success. This has been a huge problem is automated scripts that don't realize a deployment failed before moving on to the next step.
Additional information
See the README in the repo.
SFDX CLI Version(to find the version of the CLI engine run sfdx --version): sfdx-cli/7.85.1-2fb9e41053 win32-x64 node-v12.18.3
SFDX plugin Version(to find the version of the CLI plugin run sfdx plugins --core) sfdx-cli 7.85.1
OS and version:
Windows 10
Reacted by Azlam, Doug Midgley, Theodoor van Donge, Nikhil Sharma, Fırat Esmer and moelalaoui
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.
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.
For any who come after. I opened support case number 40502104 for the problem with the REST API and they indicated that it will be handled as part of the internal work item referenced above, W-8910494.
A fix for this is in progress. Also, the source commands are switching back to SOAP in the next latest-rc release (probably in an hour or 2). We'll add an env var to use the REST API, which will eventually become the default.
I don't have a big objection but going that route means I'm going to have a more difficult transition period where I have to sync source code updates with DX version updates.
Right now my scratch org build script flips between REST and SOAP deployments a couple of times mid-script. Of course that doesn't work right now for anyone that has updated. I'm going to have to update that script once the new release comes out then push the team to update DX as well as rebase/update all feature branches to be based off of an updated root branch. I'll also have to update our build server to handle the new version and CI/CD runs won't work while that is transitioning.
It isn't a deal breaker for me but will take some additional effort to make work well. I don't know if it will have a bigger impact on others as I don't think the REST API is deliberately leveraged all that often.
I think I'll watch the RC branch and get the ENV name from there. Then I'll have my script setting both of those for the time being, getting that in about a week early will help a lot in that transition.
Let me clarify because you shouldn't have to modify your scripts too much with the change going into latest-rc today.
Right now in latest: mdapi:deploy uses REST but you can switch to SOAP with the --soapdeploy flag source:deploy and source:push use REST and you can't switch to SOAP (regression)
Coming in latest-rc today: mdapi:deploy is unchanged source:deploy and source:push use SOAP and you can't switch to REST (matches v50 behavior)
Coming in a future latest-rc:
An environment variable to control SOAP/REST for the source commands. Use this to switch the source commands to use REST, which will eventually be the default but probably not until v52.
I don't know your CI scripts but I think you could either pin to some v50 version temporarily or use the latest-rc version coming out today. If you're able to, it would probably be good to have CI that uses latest and latest-rc, with errors from latest-rc providing an early warning. Ideally, we could jump on early warnings so that they never become bugs in latest.
@shetzel this might be better to have some direct communication but I'll try and explain what I can. Let me know if it would help to setup a meeting and to walk you through any of this.
If you change source:deploy and source:push so I can't get to the REST API then you will break me. My current scripts do most of my building using source:deploy using SOAP and flipping it to REST for my StaticResource deploys, I'm over the 50MB total file size limit for SOAP and have been using REST for those items. I have a workaround that loads them via the tooling API that I took out of the system when we started using the REST API and I could add that back if needed. I think I still have the custom plugin installed on users machines.
For the environment variable, I'm going to have to coordinate between where we actively flip the configuration attribute to moving to actively flipping the environment variable. Right now to deal with this I've added the --soapdeploy flag to my source:deploy command and adjusted the script version on my machine only, now I'm building scratch orgs for anyone on my team that needs them because my manipulated version is the only one that is functional. Getting everyone on the same version of source and the same version of SFDX at the same time will be difficult and I'm going to have a problem window where some users will be broken because of this.
My primary complaint is that the existing mechanism is being removed and a replacement is being added without a crossover between those two states to allow customers a window to change and adapt. You're making it very likely that I will have at least a small window where things are broken for some of my users. Add to that it also sounds like you're planning a larger gap where neither of these methods will work. Hopefully you can see where I'm coming from and why I'm raising the problem flag.
With the latest version (7.91.0-6a6ed69ebe), I am getting
`
PS C:\xxxx> sfdx force:source:push -u MyScratchOrg
*** Deploying with REST ***
ERROR running force:source:push:
Illegal Request
You have sent us an Illegal URL or an improperly formatted request.
For those of you seeing this error: You have sent us an Illegal URL or an improperly formatted request.
Please provide as many details as you can. At a minimum, CLI version and salesforcedx plugin version. OS. The command with parameters (values can be obfuscated or fake). If possible, get the URL that was used in the request. Choose whatever tool you like to do that or optionally debug the code.
As was stated earlier in this thread you can switch to use SOAP instead of REST by sfdx config:set restDeploy=false or the SFDX_REST_DEPLOY env var to workaround any REST deploy errors.
Reacted by Zafer AYDIN, Hamza Siddiqui and Irfan Khan
sfdx force:source:push -f --json --loglevel=trace
{
"status": 1,
"name": "SfdxError",
"message": "\n\n\n\n\n\n<html>\n<head><title>An internal server error has occurred</title></head>\n<body>\n\n\n<div style=\"display:none;\" id=\"errorTitle\">An internal server error has occurred</div>\n<div style=\"display:none;\" id=\"errorDesc\">An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact <a href=\"https://help.salesforce.com/apex/hthome\">Salesforce Support</a>. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. <br/><br/>Thank you again for your patience and assistance. And thanks for using salesforce.com!</div>\n<table cellspacing=10>\n<tr><td><span style=\"font-weight: bold; font-size: 12pt;\">An internal server error has occurred</span></td></tr>\n<tr><td>\nAn error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact <a href=\"https://help.salesforce.com/apex/hthome\">Salesforce Support</a>. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. <br/><br/>Thank you again for your patience and assistance. And thanks for
using salesforce.com!\n<br><br>\nError ID: 1104561287-91770 (1534884652)\n</td>\n</tr>\n<tr><td>\n<br clear=\"all\"><br><br>\n\n\n</td></tr>\n</table>\n\n</td></tr>\n</table>\n\n\n\n</body>\n</html>\n",
"exitCode": 1,
"commandName": "SourcePushCommand",
"stack": "SfdxError: \n\n\n\n\n\n<html>\n<head><title>An internal server error has occurred</title></head>\n<body>\n\n\n<div style=\"display:none;\" id=\"errorTitle\">An internal server error has occurred</div>\n<div style=\"display:none;\" id=\"errorDesc\">An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact <a href=\"https://help.salesforce.com/apex/hthome\">Salesforce Support</a>. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. <br/><br/>Thank you again for
your patience and assistance. And thanks for using salesforce.com!</div>\n<table cellspacing=10>\n<tr><td><span style=\"font-weight: bold; font-size: 12pt;\">An internal server error has occurred</span></td></tr>\n<tr><td>\nAn error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact <a href=\"https://help.salesforce.com/apex/hthome\">Salesforce Support</a>. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. <br/><br/>Thank you again for your patience and assistance. And thanks for using salesforce.com!\n<br><br>\nError ID: 1104561287-91770 (1534884652)\n</td>\n</tr>\n<tr><td>\n<br clear=\"all\"><br><br>\n\n\n</td></tr>\n</table>\n\n</td></tr>\n</table>\n\n\n\n</body>\n</html>\n\n at Function.wrap (C:\\Users\\chris\\AppData\\Local\\sfdx\\client\\7.93.0-9e2365b\\node_modules\\@salesforce\\core\\lib\\sfdxError.js:169:20)\n at Request._callback (C:\\Users\\chris\\AppData\\Local\\sfdx\\client\\7.93.0-9e2365b\\node_modules\\salesforce-alm\\dist\\lib\\core\\force.js:587:41)\n
at Request.self.callback (C:\\Users\\chris\\AppData\\Local\\sfdx\\client\\7.93.0-9e2365b\\node_modules\\request\\request.js:185:22)\n at Request.emit (node:events:369:20)\n at Request.<anonymous> (C:\\Users\\chris\\AppData\\Local\\sfdx\\client\\7.93.0-9e2365b\\node_modules\\request\\request.js:1154:10)\n at Request.emit (node:events:369:20)\n at IncomingMessage.<anonymous> (C:\\Users\\chris\\AppData\\Local\\sfdx\\client\\7.93.0-9e2365b\\node_modules\\request\\request.js:1076:12)\n at Object.onceWrapper (node:events:475:28)\n at IncomingMessage.emit (node:events:381:22)\n at endReadableNT (node:internal/streams/readable:1307:12)\n at processTicksAndRejections (node:internal/process/task_queues:81:21)",
"warnings": []
}
Edit: As mentioned, using sfdx config:set restDeploy=false works. These errors occur when using REST.
As of the 51.7.1 release yesterday the force:source:* and force:mdapi:* commands are back to using SOAP as the default as well as appropriately exiting and printing HTML errors to the terminal when they come back from the REST API.
Activity
github-actions commentedon Feb 18, 2021
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.
mshanemc commentedon Feb 19, 2021
thanks for the cool repro for proving an intermittent bug (repeat until failure).
There's a big revision in progress to the deploy, which won't use that force.js file.
We can use this issue as a test case (mock html from the api AND proper exit code)
github-actions commentedon Feb 19, 2021
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.
git2gus commentedon Feb 19, 2021
This issue has been linked to a new work item: W-8910494
aheber commentedon Feb 23, 2021
For any who come after. I opened support case number 40502104 for the problem with the REST API and they indicated that it will be handled as part of the internal work item referenced above, W-8910494.
CXCAlfo commentedon Feb 25, 2021
I am not sure if my issue is related to this but minutes after updating SFDX to sfdx-cli/7.88.4-3b2e55c3f1 win32-x64 node-v14.15.4
I created a new scratch org and then did a push -f.
I get
*** Deploying with REST ***
SyntaxError: Unexpected token < in JSON at position 1
Then a handful of errors.
shetzel commentedon Feb 26, 2021
A fix for this is in progress. Also, the source commands are switching back to SOAP in the next latest-rc release (probably in an hour or 2). We'll add an env var to use the REST API, which will eventually become the default.
aheber commentedon Feb 26, 2021
@shetzel will the mentioned change restore the config flag or be limited to a new environment variable?
shetzel commentedon Feb 26, 2021
We're thinking it would be a new env var that would only apply to the source commands.
aheber commentedon Feb 26, 2021
I don't have a big objection but going that route means I'm going to have a more difficult transition period where I have to sync source code updates with DX version updates.
Right now my scratch org build script flips between REST and SOAP deployments a couple of times mid-script. Of course that doesn't work right now for anyone that has updated. I'm going to have to update that script once the new release comes out then push the team to update DX as well as rebase/update all feature branches to be based off of an updated root branch. I'll also have to update our build server to handle the new version and CI/CD runs won't work while that is transitioning.
It isn't a deal breaker for me but will take some additional effort to make work well. I don't know if it will have a bigger impact on others as I don't think the REST API is deliberately leveraged all that often.
I think I'll watch the RC branch and get the ENV name from there. Then I'll have my script setting both of those for the time being, getting that in about a week early will help a lot in that transition.
shetzel commentedon Feb 26, 2021
Let me clarify because you shouldn't have to modify your scripts too much with the change going into latest-rc today.
Right now in latest:
mdapi:deployuses REST but you can switch to SOAP with the--soapdeployflagsource:deployandsource:pushuse REST and you can't switch to SOAP (regression)Coming in latest-rc today:
mdapi:deployis unchangedsource:deployandsource:pushuse SOAP and you can't switch to REST (matches v50 behavior)Coming in a future latest-rc:
An environment variable to control SOAP/REST for the source commands. Use this to switch the source commands to use REST, which will eventually be the default but probably not until v52.
I don't know your CI scripts but I think you could either pin to some v50 version temporarily or use the latest-rc version coming out today. If you're able to, it would probably be good to have CI that uses latest and latest-rc, with errors from latest-rc providing an early warning. Ideally, we could jump on early warnings so that they never become bugs in latest.
aheber commentedon Feb 26, 2021
@shetzel this might be better to have some direct communication but I'll try and explain what I can. Let me know if it would help to setup a meeting and to walk you through any of this.
If you change
source:deployandsource:pushso I can't get to the REST API then you will break me. My current scripts do most of my building usingsource:deployusing SOAP and flipping it to REST for my StaticResource deploys, I'm over the 50MB total file size limit for SOAP and have been using REST for those items. I have a workaround that loads them via the tooling API that I took out of the system when we started using the REST API and I could add that back if needed. I think I still have the custom plugin installed on users machines.For the environment variable, I'm going to have to coordinate between where we actively flip the configuration attribute to moving to actively flipping the environment variable. Right now to deal with this I've added the
--soapdeployflag to mysource:deploycommand and adjusted the script version on my machine only, now I'm building scratch orgs for anyone on my team that needs them because my manipulated version is the only one that is functional. Getting everyone on the same version of source and the same version of SFDX at the same time will be difficult and I'm going to have a problem window where some users will be broken because of this.My primary complaint is that the existing mechanism is being removed and a replacement is being added without a crossover between those two states to allow customers a window to change and adapt. You're making it very likely that I will have at least a small window where things are broken for some of my users. Add to that it also sounds like you're planning a larger gap where neither of these methods will work. Hopefully you can see where I'm coming from and why I'm raising the problem flag.
16 remaining items
CrownSeven commentedon Mar 4, 2021
Updated to 7.90.2-b8f9206a5c win32-x64 node-v14.15.4. I have set restDeploy=false. This error is STILL occurring.
pserquiz commentedon Mar 4, 2021
@shetzel yeah couldn't really do that in my current project, I just uninstalled it and installed an older version for now. Thanks
zerkz commentedon Mar 5, 2021
@CrownSeven make sure your salesforcedx is on latest and isn't still the downgraded plugin.
mhamzas commentedon Mar 15, 2021
With the latest version (7.91.0-6a6ed69ebe), I am getting
`
PS C:\xxxx> sfdx force:source:push -u MyScratchOrg
*** Deploying with REST ***
ERROR running force:source:push:
`
MJ12358 commentedon Mar 15, 2021
I am also seeing this error when deploying.
sfdx force:source:deploy --sourcepath c:\ --json --loglevel fatal
ended with exit code 1
SFDX Version: sfdx-cli/7.91.0-6a6ed69ebe win32-x64 node-v14.15.4
irfanKhanSage commentedon Mar 15, 2021
I am getting this 'Illegal Request' html error myself, its actually very random. When I restart my VS Code for first time it works but is back again.
ricofairsailcom commentedon Mar 15, 2021
same issue as @mhamzas and @MJ12358 but with the command "sfdx force:source:push"
mhamzas commentedon Mar 15, 2021
The only solution that worked for me is: #884 (comment)
@ricofairsailcom @irfanKhanSage @MJ12358
ricofairsailcom commentedon Mar 15, 2021
The issue is only for Windows machine apparently, just downgrading to v7.81 should work.
npm install --global [email protected]
shetzel commentedon Mar 16, 2021
For those of you seeing this error:
You have sent us an Illegal URL or an improperly formatted request.Please provide as many details as you can. At a minimum, CLI version and salesforcedx plugin version. OS. The command with parameters (values can be obfuscated or fake). If possible, get the URL that was used in the request. Choose whatever tool you like to do that or optionally debug the code.
As was stated earlier in this thread you can switch to use SOAP instead of REST by
sfdx config:set restDeploy=falseor theSFDX_REST_DEPLOYenv var to workaround any REST deploy errors.ApraChris commentedon Mar 26, 2021
Hi @shetzel,
I'm having the same issue with the illegal URL.
Here are my details - let me know if you need any more details:
Edit: As mentioned, using
sfdx config:set restDeploy=falseworks. These errors occur when using REST.LawrenceLoz commentedon Mar 30, 2021
@shetzel I'm getting the illegal URL error, but I've only seen this using the built-in VS Code command palette push function. Behaviours I've seen:
sfdx force:source:pushto scratch org using command line: Workssfdx force:source:push --json --loglevel fatalto scratch org using command line: WorksI've also seen the outcomes described in 2-4 while working on a scratch org created by another user which was added through authentication.
Quite elusive but hope this is helpful. I'm not sure how I can view the URL used but happy to try if there's a way to see this detail
Error output:
SFDX core, OS and node versions:
sfdx-cli/7.93.1-762bca056d win32-x64 node-v14.15.4(Windows 10.0.19042)SFDX plugin versions:
Salesforce CLI Integration VS Code plugin version
v51.6.0mrityunjaya-tiwari commentedon Apr 9, 2021
On VS Code we can run command: sfdx config:set restDeploy=false
RodEsp commentedon Apr 9, 2021
As of the 51.7.1 release yesterday the
force:source:*andforce:mdapi:*commands are back to using SOAP as the default as well as appropriately exiting and printing HTML errors to the terminal when they come back from the REST API.