-
Notifications
You must be signed in to change notification settings - Fork 78
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
predeploy hook result doesn't include all files when there is API name collision #1428
Comments
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. |
@filiprafalowicz - thanks for posting. The docs and the samples in that repo are currently wrong. I have a PR to fix the samples: salesforcecli/plugin-metadata-hook-demo#147 |
@shetzel I just tested the changes in new sfdx version and they look promising, but there are couple of things that I have noticed. They may not be fully related to the initial issue I reported here as it seems to be fixed, but they are related to the predeploy hook:
When running
|
|
Hey @mshanemc. For the first one, I will try to reproduce it with a smaller codebase and open a separate bug if the issue persists. For the second one, I read your post and while it makes sense for the deploy command, I can't see how the workarounds listed there can work for the push. While creating custom push command would give me more flexibility in doing what I need, it will also give me a lot of disadvantages as I couldn't leverage any of the new features you add to original push command and I would need to maintain my custom command. I feel like with this change of removing mdapiFilePath, predeploy hook for push command is useless as it will always make local changes to the files I have in my project and they won't be rolled back. As an example, I want to replace secrets for Named Credentials and have XML in my project with placeholders like this:
So now every time this file is included in the push, I would like to make sure my predeploy hook can replace these placeholders with actual data secrets, but I don't want to have the files changed in my local project. These secrets can be stored on some secure data storage that requires MFA to retrieve them and I don't want to keep them as plain text on my machine. I have similar scenario with custom labels - let's say I store all of the strings outside SF in external system where Content Team can manage and translate them. My Custom Labels file would store labels without values. Now every time Custom Labels file is included in the push, I want to be able to call the API to pull the labels from that system and make sure they are pushed to my scratch org correctly. If I do that logic in the current predeploy hook, the changes that were pulled from the service will remain in my CustomLabels file and if I want to add one more label, I will need to remember to revert local changes to this file first and then add a new label. This is the experience we would like to avoid. In general I was hoping predeploy hook, or maybe some new hook, could be fired to make changes to the files on the fly, before they are streamed to that in-memory zip file. I don't know how much it can slow down the process, but let's keep in mind we won't be modifying every file that is included in the push. If you have 10 integrations and that's the only thing you want to dynamically inject into XML files then we need to modify only 10 files like that. Maybe if executing the hook for every file would be to slow, we can at least build some listeners and execute it only for certain files that you are subscribed to. Or maybe, worst case, we can still support old way of zipping the files based on the parameter to the push command. |
This issue has not received a response in 60 days. It will auto-close in 7 days unless a response is posted. |
@mshanemc following up on this one - I am unable to check how predeploy hook looks right now because of ongoing plugins issue (#1664) but I was wondering if you had a chance to review my last comment and if there is any way to accomplish the same with currently available options. In general what I described would work with the old way of how predeploy hook was designed and with API name collision issue fixed. Right now I am not sure what would be the use case for predeploy hook if it modifies your files locally. |
We've got a design for string replacements during deploys that would also work for across CLIs and VSCode. But I don't know when we'll get to it. |
the final result on this one is to use the string replacements feature we shipped recently. We're not going to fix bugs like this one in the deprecated |
Summary
Result type in predeploy hook for force:source:push command has following structure:
(per https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_customize_hooks_list.htm)
Because aggregateName is essentially just an API name this is causing issues when two different metadata types share the same name. As an example, if you change Account.object and Account.workflow and run push command, this is how result will look like:
There is no information about Account.workflow file that was also pushed at the same time. Additionally, if you do the same with force:source:deploy command, it will work as expected, as result does not have an object with API Name as a key, but it stores array of metadata components that are being deployed. I think you could either change aggregateName in the result to include metadata type like "CustomObject:Account" or align with the structure of the result from the deploy command.
Also, I saw similar issue, but for the different hook already reported: #743. Not sure if that was fixed or not.
Without that fixed, predeploy hook can be very often useless for larger organizations with a lot of metadata where API Name collision can occur a lot of times.
Steps To Reproduce:
Expected result
Both Account.object and Account.workflow should be included in the predeploy hook result.
Actual result
Only Account.object is included in the predeploy hook result.
System Information
The text was updated successfully, but these errors were encountered: