cli icon indicating copy to clipboard operation
cli copied to clipboard

MetadataTransferError: Metadata API request failed: <h1>Bad Message 400</h1><pre>reason: Bad Request</pre>

Open AllanOricil opened this issue 2 years ago • 4 comments

Summary

400 bad request when running sfdx force:source:deploy:report -u <ORG_ALIAS> -i <JOB_ID> -w 60 --json

image

Steps To Reproduce:

<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>COM_Account</members>
        <members>COM_Campaign</members>
        <members>COM_Case</members>
        <members>COM_Contact</members>
        <members>COM_Lead</members>
        <members>COM_LiveChatTranscript</members>
        <members>COM_OwnedDomain</members>
        <members>COM_TaskTrigger</members>
        <members>COM_User</members>
        <members>DSP_DocumentSigningReqEvent</members>
        <members>DSP_DocumentSigningReqSigner</members>
        <members>DSP_DocumentSigningRequest</members>
        <members>KNO_Knowledge</members>
        <members>NUM_Series</members>
        <members>SER_LiveChatTranscriptEvent</members>
        <name>ApexTrigger</name>
    </types>
    <types>
        <members>BypassTriggerSetting__mdt.DisableAccountTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableAllTriggers__c</members>
        <members>BypassTriggerSetting__mdt.DisableCampaignTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableCaseTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableContactTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableDocSigningRequestSignerTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableDocumentSigningRequestTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableKnowledgeTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableLeadTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableLiveChatTranscriptEventTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableLiveChatTranscriptTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableOwnedDomainTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableSeriesTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableTaskTrigger__c</members>
        <members>BypassTriggerSetting__mdt.DisableUserTrigger__c</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>BypassTriggerSetting__mdt</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>BypassTriggerSetting.Admin</members>
        <name>CustomMetadata</name>
    </types>
    <types>
        <members>BypassTriggerSetting__mdt-BypassTriggerSetting Layout</members>
        <name>Layout</name>
    </types>
    <version>55.0</version>
</Package>

1 - run sfdx force:source:deploy -u $ORG_ALIAS -x $MANIFEST_PATH -l RunLocalTests -w 0 -g -c --json image

2 - run sfdx force:source:deploy:report -u $ORG_ALIAS -i $JOB_ID -w 60 --json image

Expected result

sfdx force:source:deploy:report -u $ORG_ALIAS -i $JOB_ID -w 60 --json should not output <h1>Bad Message 400</h1><pre>reason: Bad Request</pre>

Actual result

sfdx force:source:deploy:report -u $ORG_ALIAS -i $JOB_ID -w 60 --json outputs <h1>Bad Message 400</h1><pre>reason: Bad Request</pre>

System Information

{
  "cliVersion": "sfdx-cli/7.169.1",
  "architecture": "darwin-x64",
  "nodeVersion": "node-v16.17.0",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 1.3.0 (core)",
    "@oclif/plugin-commands 2.2.0 (core)",
    "@oclif/plugin-help 5.1.12 (core)",
    "@oclif/plugin-not-found 2.3.1 (core)",
    "@oclif/plugin-plugins 2.1.0 (core)",
    "@oclif/plugin-update 3.0.0 (core)",
    "@oclif/plugin-version 1.1.2 (core)",
    "@oclif/plugin-warn-if-update-available 2.0.4 (core)",
    "@oclif/plugin-which 2.1.0 (core)",
    "alias 2.1.0 (core)",
    "apex 1.2.0 (core)",
    "auth 2.2.5 (core)",
    "community 2.0.1 (core)",
    "config 1.4.19 (core)",
    "custom-metadata 2.0.0 (core)",
    "data 2.1.2 (core)",
    "generator 2.0.2 (core)",
    "info 2.1.0 (core)",
    "limits 2.0.1 (core)",
    "org 2.2.3 (core)",
    "packaging 1.9.1 (core)",
    "schema 2.1.3 (core)",
    "signups 1.2.0 (core)",
    "source 2.0.13 (core)",
    "telemetry 2.0.0 (core)",
    "templates 55.1.0 (core)",
    "trust 2.0.4 (core)",
    "user 2.1.2 (core)",
    "@salesforce/sfdx-plugin-lwc-test 1.0.1 (core)",
    "salesforce-alm 54.8.1 (core)",
    "sfdx-git-delta 5.5.0 (user)"
  ],
  "osVersion": "Darwin 21.5.0",
  "shell": "zsh",
  "rootPath": "/Users/allanoricil/.local/share/sfdx/client/7.169.1-15b850c"
}

Additional information

NA

AllanOricil avatar Sep 28 '22 12:09 AllanOricil

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.

github-actions[bot] avatar Sep 28 '22 12:09 github-actions[bot]

intermittently, or reproducible? Asking because I've seen this mdapi error on occasion.

mshanemc avatar Oct 04 '22 16:10 mshanemc

intermittently, or reproducible? Asking because I've seen this mdapi error on occasion.

It happened only once. I just wanted to let you know that the error message was not treated. It does not say exactly what went wrong.

AllanOricil avatar Oct 04 '22 18:10 AllanOricil

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

github-actions[bot] avatar Oct 12 '22 02:10 github-actions[bot]

@mshanemc this error just happened again. This error message just needs to be treated properly, I believe. I can take a look at it later too, if you don't mind.

logs_8478.zip

image

AllanOricil avatar Dec 01 '22 13:12 AllanOricil

This issue has been linked to a new work item: W-12150499

git2gus[bot] avatar Dec 01 '22 14:12 git2gus[bot]

Not sure if it is related, but I noticed that when the "developer console" is opened, it displays the same error:

image

Maybe this error message should be handled by the Tooling API team?

AllanOricil avatar Dec 01 '22 14:12 AllanOricil

Yeah, it's definitely not the CLI's bug. It's more of a question of, "does it only fail intermittently so that we'd want to retry it if we see that error?"

If so, we can add it to this list https://github.com/forcedotcom/source-deploy-retrieve/blob/39df234b8f912fd019d1280b2b535b73f0c73f3b/src/client/metadataTransfer.ts

mshanemc avatar Dec 01 '22 14:12 mshanemc

I can't really answer your question. But I believe we can just do what you suggested because when I ran that job again, no errors appeared. But there is still a chance that if we retry the same request multiple times in a short period of time, we will just end up with the same error multiple times. This error message does not help us that much. It is more like a 5xx than a 4xx, in my opinion. Maybe you could also look for answers internally with the tooling api team to see if they could track and fix this error.

AllanOricil avatar Dec 01 '22 15:12 AllanOricil

Hi @mshanemc ,

I just wanted to add to this thread - we're seeing this happen on a semi-regular basis during pushes ("sfdx force:source:push") for one of our products. The error message is exactly the same Metadata API request failed: <h1>Bad Message 400</h1><pre>reason: Bad Request</pre> and the stack suggests it's also originating in MetadataApiDeploy.pollStatus().

It's intermittent, but the code being deployed is static (I'm deploying the same commit each time) so it's not related to any changes on our end. It's currently failing ~16% of the time with this error.

If the CLI could gracefully handle this error and retry as per ECONNRESET, it would really help.

Thanks!

rhobkirkcertinia avatar Dec 02 '22 10:12 rhobkirkcertinia

I am getting the same error when I am validating the deployment against the org.

ERROR running force:source:deploy: Metadata API request failed:

Bad Message 400

reason: Bad Request

irfanlai avatar Dec 02 '22 15:12 irfanlai

we also have this error from time to time. I think it happens when deployment/validation job runs quite a long time, i.e hours. In our project we have 10k + metadata components, and the validation job takes around 2hours so we face this issue almost every day in different pipelines.

steals avatar Dec 06 '22 09:12 steals