-
Notifications
You must be signed in to change notification settings - Fork 102
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: correct apiVersion and sourceApiVersion values before transfer and send events #791
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.
Are there UTs testing that the api version is set based on the hierarchy?
Those tests are in progress. |
componentSet.apiVersion ??= apiversion; | ||
componentSet.sourceApiVersion ??= sourceapiversion; | ||
logger.debug(`ComponentSet apiVersion = ${componentSet.apiVersion}`); | ||
logger.debug(`ComponentSet sourceApiVersion = ${componentSet.sourceApiVersion}`); |
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.
checking my understanding...if I got a componentSet via componentSetBuilder, and used a manifest, then sourceApiVersion would have been set by CSB.
but not if the consumer passed in a sourceApiVersion -- then that would undo whatever the manifest version is?
So...would it make sense to disallow that behavior (like a clever union type on ComponentSetOptions
that doesn't allow those props to co-exist)? Or do you think there's a use case for it?
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.
The sourceApiVersion
set by ComponentSet.fromManifest()
takes precedence. The sourceApiVersion
passed in as an option to CSB would be ignored.
src/client/metadataApiRetrieve.ts
Outdated
@@ -236,6 +244,11 @@ export class MetadataApiRetrieve extends MetadataTransfer<MetadataApiRetrieveSta | |||
requestBody.singlePackage = this.options.singlePackage; | |||
} | |||
|
|||
// Debug output for API version used for retrieve | |||
const manifestVersion = manifestData.version ?? requestBody.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.
see above...there's definitely something in manifestData.version
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.
Yes, you're correct. This is a "suspenders and a belt" bit of code that I can modify to just use manifestData.version
. I'll make that change.
result.apiVersion = manifest.apiVersion; | ||
|
||
result.logger.debug(`Setting sourceApiVersion of ${manifest.apiVersion} on ComponentSet from manifest`); | ||
result.sourceApiVersion = manifest.apiVersion; | ||
result.fullName = manifest.fullName; |
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.
FYI: manifest resolver never returns a full name. It's optional in the return type, but never set.
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.
I'm not even sure what that is supposed to represent
QA notes: ✅ source: deploy package.xml version wins over org, for sourceApiVersion. ❓ v52 in package.xml, 55.0 in project, and no version in package.xml no version in package.xml, no version in project, --apiversion 50 same, but remove the flag (both use org's version) add 53.0 as local config 53.0 in config, --apiversion 51.0 (flag should win) retrieves53.0 in config, --apiversion 51.0 , 45.0 in manifest (manifest should win) 53.0 in config, --apiversion 51.0 , 53.0 in project, -p classes (project should win) remove project value (flag should win) [unset config, no flag] (org should win) add env at 49.0 add 53 in project, still env 49.0 add 48.0 flag, still 53 in project, still env 49.0 (flag should win on connection, but project wins on sourceApiVersion) convertsource:convert (nothing in project, no org involved). Coverage report wins? source:convert (53 in project, no org involved). project wins source:convert (52 in config). manifest createforce:source:manifest:create -m ApexClass same command, but no value in project (expect v52 from config) |
What does this PR do?
Corrects the code that determines the apiVersion and sourceApiVersion before sending a deploy or retrieve. Also emits an event with this data just before sending so that consumers can act upon it (e.g., display useful output).
The proper priority for determining the API version of the connection (items higher on the list take precedence) is:
apiversion
command flagSFDX_API_VERSION
env varThe proper priority for determining the manifest version (items higher on the list take precedence) is:
<version>
in package.xmlsourceApiVersion
in sfdx-project.jsonapiversion
command flagSFDX_API_VERSION
env varWhat issues does this PR fix or reference?
@W-12146860@