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

fix: use appexchange org for last resort api version #1219

Merged
merged 4 commits into from
Jan 23, 2024

Conversation

shetzel
Copy link
Contributor

@shetzel shetzel commented Jan 19, 2024

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@

@shetzel shetzel requested a review from a team as a code owner January 19, 2024 21:33
Copy link
Contributor

@mshanemc mshanemc left a 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.

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;
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@mshanemc mshanemc left a 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.

@shetzel shetzel merged commit c9f15b2 into main Jan 23, 2024
68 checks passed
@shetzel shetzel deleted the sh/use-org62-for-api-version branch January 23, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants