-
Notifications
You must be signed in to change notification settings - Fork 115
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
fix: use appexchange org for last resort api version #1219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA'd, works fine.
src/registry/coverage.ts
Outdated
return +lastVersionEntry.version; | ||
if (apiVer === undefined) { | ||
const apiVersionsUrl = 'https://appexchange.salesforce.com/services/data'; | ||
const lastVersionEntry = (await got(getProxiedOptions(apiVersionsUrl)).json<ApiVersion[]>()).pop() as ApiVersion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have a mild preference for .at(-1)
over .pop()
to avoid using the mutating Array methods (fine here, no side effects, just more of "if you never use it, you don't have to think about whether this time is safe").
const lastVersionEntry = (await got(getProxiedOptions(apiVersionsUrl)).json<ApiVersion[]>()).pop() as ApiVersion; | ||
apiVer = +lastVersionEntry.version; | ||
} | ||
return apiVer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more meta--if this does fail (network issues, org down, etc) would the error be meaningful for users to know what's happening?
it's
Uncaught RequestError: getaddrinfo ENOTFOUND appexchange.salesforce.com
And I think it'd be nice to tell them why we were doing that and what they might do about it (ex: setting or passing in an api version). It's hard for SDR to know what they're doing to be more specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internally, the error is never displayed to an end user because if it fails, the code in ComponentSet
will just use api version 58.0.
Seems this method is exported though which means anyone could call it, and in that case this function has a misleading name and could cause other problems. I would argue this should not be exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA'd, works fine.
What does this PR do?
When an API version is needed yet not provided in other ways to the SDR APIs, make a call to the appexchange org to get the most recent API version. Also, save the result so that all other calls to
getCurrentApiVersion()
on the same process use that value rather than making another call to that endpoint.What issues does this PR fix or reference?
@W-14848514@