Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sm/qa redirect bug #667

Merged
merged 3 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions messages/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ Connection has no instanceUrl.
# noInstanceUrlError.actions

Make sure the instanceUrl is set in your command or config.

# noApiVersionsError

Org failed to respond with its list of API versions. This is usually the result of domain changes like activating MyDomain or Enhanced Domains

# noApiVersionsError.actions

Re-authenticate to the org.
6 changes: 6 additions & 0 deletions src/org/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const messages = Messages.load('@salesforce/core', 'connection', [
'incorrectAPIVersionError',
'domainNotFoundError',
'noInstanceUrlError',
'noApiVersionsError',
]);

const clientId = `sfdx toolbelt:${process.env.SFDX_SET_CLIENT_IDS || ''}`;
Expand Down Expand Up @@ -227,6 +228,11 @@ export class Connection<S extends Schema = Schema> extends JSForceConnection<S>
await this.isResolvable();
type Versioned = { version: string };
const versions: Versioned[] = await this.request<Versioned[]>(`${this.instanceUrl}/services/data`);
// if the server doesn't return a list of versions, it's possibly a instanceUrl issue where the local file is out of date.
if (!Array.isArray(versions)) {
this.logger.debug(`server response for retrieveMaxApiVersion: ${versions}`);
throw messages.createError('noApiVersionsError');
}
this.logger.debug(`response for org versions: ${versions.map((item) => item.version).join(',')}`);
const max = ensure(maxBy(versions, (version: Versioned) => version.version));

Expand Down
15 changes: 15 additions & 0 deletions test/unit/org/connectionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ describe('Connection', () => {
});
});

it('throws error when no valid API version', async () => {
const conn = await Connection.create({ authInfo: fromStub(testAuthInfoWithDomain) });

$$.SANDBOX.restore();
$$.SANDBOX.stub(MyDomainResolver.prototype, 'resolve').resolves(TEST_IP);
$$.SANDBOX.stub(conn, 'isResolvable').resolves(true);
$$.SANDBOX.stub(JSForceConnection.prototype, 'request').resolves('');

try {
await shouldThrow(conn.retrieveMaxApiVersion());
} catch (e) {
expect(e).to.have.property('name', 'NoApiVersionsError');
}
});

it('create() should throw on DNS errors', async () => {
$$.SANDBOX.restore();
$$.SANDBOX.stub(MyDomainResolver.prototype, 'resolve').rejects({ name: DNS_ERROR_NAME });
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@
integrity sha512-RSKRfYX20dyH+elbJK2uqAkVyucL+xXzhqlMD5/ZXx+dAAwpyB7HsvnHe/ZUGOF+xLr5Wx9/JoXVTj6BQE2/oA==

"@babel/runtime-corejs3@^7.12.5":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.18.9.tgz#7bacecd1cb2dd694eacd32a91fcf7021c20770ae"
integrity sha512-qZEWeccZCrHA2Au4/X05QW5CMdm4VjUDCrGq5gf1ZDcM4hRqreKrtwAn7yci9zfgAS9apvnsFXiGBHBAxZdK9A==
version "7.19.1"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.19.1.tgz#f0cbbe7edda7c4109cd253bb1dee99aba4594ad9"
integrity sha512-j2vJGnkopRzH+ykJ8h68wrHnEUmtK//E723jjixiAl/PPf6FhqY/vYRcMVlNydRKQjQsTsYEjpx+DZMIvnGk/g==
dependencies:
core-js-pure "^3.20.2"
core-js-pure "^3.25.1"
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.12.5":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
integrity sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==
version "7.19.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.19.0.tgz#22b11c037b094d27a8a2504ea4dcff00f50e2259"
integrity sha512-eR8Lo9hnDS7tqkO7NsV+mKvCmv5boaXFSZ70DnfhcgiEne8hv9oCEd36Klw74EtizEqLsy4YnW8UWwpBVolHZA==
dependencies:
regenerator-runtime "^0.13.4"

Expand Down Expand Up @@ -1833,15 +1833,15 @@ copy-descriptor@^0.1.0:
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
integrity sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==

core-js-pure@^3.20.2:
version "3.23.5"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.23.5.tgz#23daaa9af9230e50f10b0fa4b8e6b87402be4c33"
integrity sha512-8t78LdpKSuCq4pJYCYk8hl7XEkAX+BP16yRIwL3AanTksxuEf7CM83vRyctmiEL8NDZ3jpUcv56fk9/zG3aIuw==
core-js-pure@^3.25.1:
version "3.25.4"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.25.4.tgz#e8642cef4f4246a4e7c15280f5e3926118fff84b"
integrity sha512-qRbgm0ADrsNTU66UcW47YMJjXm+ShhUP2gkoEoAShT2BHO3cb5gGqLtmWpjnM6Wx9h5hMSF4uZ+jEV/8+4KCsw==

core-js@^3.6.4:
version "3.23.5"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.23.5.tgz#1f82b0de5eece800827a2f59d597509c67650475"
integrity sha512-7Vh11tujtAZy82da4duVreQysIoO2EvVrur7y6IzZkH1IHPSekuDi8Vuw1+YKjkbfWLRD7Nc9ICQ/sIUDutcyg==
version "3.25.4"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.25.4.tgz#76f6bc330a79aafbaf77e9645293351ea5d09b5b"
integrity sha512-JDLxg61lFPFYQ7U0HKoyKwVUV63VbbVTb/K73Yf+k4Mf4ZBZxCjfyrWZjTk1ZM7ZrgFSqhSIOmuzYAxG2f/reQ==

core-util-is@~1.0.0:
version "1.0.3"
Expand Down Expand Up @@ -3731,9 +3731,9 @@ jsesc@^2.5.1:
integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==

jsforce@beta:
version "2.0.0-beta.18"
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.18.tgz#2791a2e6ec15d4d8b41f0782e23b833f5dbe5678"
integrity sha512-9IKv3M/U/FCdL6G8WlFqWiBTvLx1TRmGW+JhcSWHZb0YlMLHiGNVymvLyPsvRfO9sNP6VR3A5AIntqD+UsDKkQ==
version "2.0.0-beta.19"
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.19.tgz#4a136b88d6a9f6668714c4ccbb0acd55e46ea493"
integrity sha512-WdF6hs7kukXNGvp/VRhu2DngldgiBBorsc2WA5us08oJGbEIPwn/itqYJWKJ+rfPXepz5JbkWQd48XHGjqmPpw==
dependencies:
"@babel/runtime" "^7.12.5"
"@babel/runtime-corejs3" "^7.12.5"
Expand Down