force:mdapi:deploy - versions.map is not a function
Summary
Getting the error versions.map is not a function when running force:mdapi:deploy against a Winter '23 preview instance sandbox
Steps To Reproduce:
Run sfdx force:mdapi:deploy with a valid package directory against a Winter '23 preview instance sandbox
Expected result
Package is deployed
Actual result
Get an error - versions.map is not a function
System Information
{ "cliVersion": "sfdx-cli/7.165.0", "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.3 (core)", "community 2.0.0 (core)", "config 1.4.17 (core)", "custom-metadata 2.0.0 (core)", "data 2.1.2 (core)", "generator 2.0.2 (core)", "info 2.0.1 (core)", "limits 2.0.1 (core)", "org 2.2.0 (core)", "schema 2.1.1 (core)", "signups 1.2.0 (core)", "source 2.0.12 (core)", "telemetry 2.0.0 (core)", "templates 55.1.0 (core)", "trust 2.0.3 (core)", "user 2.1.0 (core)", "@salesforce/sfdx-plugin-lwc-test 1.0.0 (core)", "salesforce-alm 54.8.1 (core)" ], "osVersion": "Darwin 21.6.0", "shell": "zsh", "rootPath": "/Users/evan-alavida/.local/share/sfdx/client/7.165.0-65b4bb0" }
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.
Yes, we have the same issue. It seems related to enhanced domains and the new instance URL which now contains the word “sandbox”. We no longer get this error after disabling enhanced domains in our sandbox and reauthenticating in the CLI.
Same issue comes up with :source: commands too.
We have reports of the same issue with mdapi:retrieve
I saw this same issue with 'versions.map' error for force:source:retrieve @leostewart 's hint about enhanced domains led me to find #1588 It might be relevant that I had previously authenticated to my sandbox PRIOR to enhanced domains being enabled. After deleting the existing auth data in my .sfdx file and reauthenticating with a new enhanced domain url, I found I was then able to successfully run force:source:retrieve
YMMV but this was enough for me to get on with it, sharing in case it helps
Same here with source commands.
ERROR running force:source:deploy: versions.map is not a function
I'm able to recreate this consistently. Each time I use 'myDomain' feature on fresh scratch org.
Immediately after deploying a new domain 'sfdx open default org' still works but I'm not able to deploy code anymore. In order to fix it I have to re-authenticate
Hello all, thank you for all the information. I believe we have a ticket already create to track this. I will follow up with the team and link to this issue.
Can some of y'all provide the following:
- what the domain is that's failing
- if you look in ~/.sfdx/[your username], is the
instanceUrlin that file correct?
I've done some testing and found the same as others. The issue occurs when enhanced domains become enabled in an org.
Test steps:
- Authenticate with a sandbox that doesn't have enhanced domains
- Retrieve - it works
- Enable enhanced domains
- Retrieve - it fails
As others have pointed out, you can workaround by logging out and back in - this will update the instanceUrl in .sfdx/[username].json.
The format of the URL in .sfdx/[username].json before: https://[mydomain]--[sandbox].my.salesforce.com and after: https://[mydomain]--[sandbox].sandbox.my.salesforce.com.
I'd hazard a guess that the issue is the following line:
const versions = await this.request(`${this.instanceUrl}/services/data`);
in connection.js retrieveMaxApiVersion() since the instanceUrl https://[mydomain]--[sandbox].my.salesforce.com/services/data now has a 301 redirect to https://[mydomain]--[sandbox].sandbox.my.salesforce.com/services/data.
My bet is that the request library doesn't follow redirects and instead is trying to look for version information in an empty body.
Debug: ERROR running force:mdapi:retrieve: versions.map is not a function *** Internal Diagnostic ***
Type: versions.map is not a function at Function.wrap (/Users/andrew.goodman/.local/share/sfdx/client/7.165.0-65b4bb0/node_modules/@salesforce/core/lib/sfError.js:61:25) at Retrieve.catch (/Users/andrew.goodman/.local/share/sfdx/client/7.165.0-65b4bb0/node_modules/@salesforce/command/lib/sfdxCommand.js:267:38) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Retrieve._run (/Users/andrew.goodman/.local/share/sfdx/client/7.165.0-65b4bb0/node_modules/@salesforce/command/lib/sfdxCommand.js:93:13) at async Config.runCommand (/Users/andrew.goodman/.local/share/sfdx/client/7.165.0-65b4bb0/node_modules/@oclif/core/lib/config/config.js:272:25) at async run (/Users/andrew.goodman/.local/share/sfdx/client/7.165.0-65b4bb0/node_modules/@oclif/core/lib/main.js:76:5)
I had the same problem with a source:retrieve command.
After reading the comment of gdman, I took a look in de json file for the current default org of my project and found it mentioned the old instanceurl. I just updated the url to https://[mydomain]--[sandbox].sandbox.my.salesforce.com and it all works again. (So, all I did really, was adding the .sandbox part of the url)
So, if you're in a hurry, this is a simple workaround without too much hassle. :-)
I was having the same issue after upgrading SFDX CLI to 7.167.x
After rollback to 7.166.1, it stopped appearing.
To be precise I am using
https://developer.salesforce.com/media/salesforce-cli/sfdx/versions/7.166.1/12dce37/sfdx-v7.166.1-12dce37-linux-x64.tar.xz
I also found that if you re-auth the org with -r https://[mydomain]--[sandbox].sandbox.my.salesforce.com this also updates the JSON for you.
This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.
I don't think this ticket is requiring more information, perhaps it's getting missed because it has the wrong label?
Even if the underlying issue isn't going to get fixed, IMO the code should be updated to not fail with 'versions.map isn't a function'. At a minimum, check there versions returned from the Salesforce API and if not throw an exception that points people in the direction of re-authorising.
Hey @gdman, sorry for the late reply.
I found we already had a WI in our backlog to fix this: W-11731922, sounds like you are right about the code not following the redirect, we'll take a look at this next week.
The fix can be tested with the sfdx CLI release candidate, version 7.172.0, or the sf CLI release candidate, version 1.49.0.
Closing as the fix is in the current production version.