sfpowerkit icon indicating copy to clipboard operation
sfpowerkit copied to clipboard

sfpowerkit:source:profile:reconcile -s removes user license details

Open loktevich opened this issue 2 years ago • 11 comments

sfdx sfpowerkit:source:profile:reconcile -s removes <userLicense> tag from profiles. As a result, all profiles after deploying have default Salesforce license, that is incorrect for some of them. The bug is critical while deploying all the metadata including custom profiles at the first time to scratch orgs.

To Reproduce

  1. Retrieve any profile (e.g. Admin) from production or sandbox org: sfdx sfpowerkit:source:profile:retrieve -n Admin -u user
  2. Ensure profile has <userLicense>Salesforce</userLicense> tag
  3. Reconcile using the source: sfdx sfpowerkit:source:profile:reconcile -s -n Admin

Expected behavior Reconciled profile should have the same tag <userLicense> as we have in the full version of the retrieved profile.

Desktop:

  • OS: Microsoft Windows [Version 10.0.19044.1766]
  • sfdx-cli/7.151.1 win32-x64 node-v14.18.2
  • Version of sfpowerkit 4.2.11

loktevich avatar Jul 27 '22 09:07 loktevich

Thanks @loktevich for raising this. The reconcile works also on license. That means that if the license does not exist in the target org, then the tag will be removed. Can you check if the license being removed exist in the targe org? Sometimes you might need to match production licenses (From the Company information page) in a Sandbox to have all licenses available in production.

genoud avatar Jul 29 '22 03:07 genoud

Hello, @genoud. reconcile -u username works as expected, but that problem with removing licenses exists only for the reconcile command with -s parameter. So, we use just the source for reconciling, not any org.

loktevich avatar Jul 29 '22 07:07 loktevich

@loktevich I found the issue. Can you test the change in the PR?

genoud avatar Aug 02 '22 00:08 genoud

Hi Genoud @genoud , no luck. Am I doing everything correctly ?

preps:

cd sfpowerkit
git fetch
git checkout issue/713
sfdx plugins:unlink
rm -rf node_modules
npm i
sfdx plugins:link

execution:

cd ../my_project
 sfdx sfpowerkit:source:profile:reconcile -n Admin -s
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.10 - Release:May 22
-------------------------------------------------------------------------------------------
Profiles Found in Project Directory 1
Initiated Profile reconcile thread :1  with a chunk of 1 profiles
Profiles queued in thread :1 :
[{"path":"profiles\\profiles\\Admin.profile-meta.xml","name":"Admin"}]
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in
TS itself.
An error occured during profile reconcile. You can rerun the command after a moment.
Worker stopped with exit code 1

busybox0 avatar Aug 02 '22 15:08 busybox0

Hi Genoud @genoud , no luck. Am I doing everything correctly ?

preps:

cd sfpowerkit
git fetch
git checkout issue/713
sfdx plugins:unlink
rm -rf node_modules
npm i
sfdx plugins:link

execution:

cd ../my_project
 sfdx sfpowerkit:source:profile:reconcile -n Admin -s
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.10 - Release:May 22
-------------------------------------------------------------------------------------------
Profiles Found in Project Directory 1
Initiated Profile reconcile thread :1  with a chunk of 1 profiles
Profiles queued in thread :1 :
[{"path":"profiles\\profiles\\Admin.profile-meta.xml","name":"Admin"}]
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in
TS itself.
An error occured during profile reconcile. You can rerun the command after a moment.
Worker stopped with exit code 1

I'm not facing this issue on my end. Can you follow the solutions proposed here https://stackoverflow.com/questions/72488958/false-expression-non-string-value-passed-to-ts-resolvetypereferencedirective

Thanks,

genoud avatar Aug 02 '22 15:08 genoud

Hi Genoud @genoud,

To avoid any side effects of local environment, I've tried to install it in docker container node:14.18-buster-slim Manually installed all the components there, but no luck. The error is a bit different though:

[object Object]
An error occured during profile reconcile. You can rerun the command after a moment.

The same error I'm getting on Windows installation after npm install ts-node-dev@latest ts-node@latest

Below is full preps and log that can be repeated. Can you please try it out ?

$ docker run -it --rm -v $PWD/..:/build   -w /build node:14.18-buster-slim  /bin/bash

# apt-get update && apt-get install git

# npm install --global sfdx-cli

# sfdx --version
sfdx-cli/7.161.0 linux-x64 node-v14.18.3

# cd /build/sfpowerkit/

# git log -1
commit 914c8fabf06df4fdb084063fb7eacb0c5680cbdb (HEAD -> issue/713, origin/issue/713)

# git status
On branch issue/713
Your branch is up to date with 'origin/issue/713'

# git clean -dxf
Removing lib/
Removing node_modules/
Removing npm-shrinkwrap.json
Removing oclif.manifest.json
Removing tsconfig.tsbuildinfo

# npm i

# sfdx plugins:link

# cd ../my_project

# sfdx sfpowerkit:source:profile:reconcile -n Admin -s
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.10 - Release:May 22
-------------------------------------------------------------------------------------------
Profiles Found in Project Directory 1
Initiated Profile reconcile thread :1  with a chunk of 1 profiles
Profiles queued in thread :1 :
[{"path":"profiles/profiles/Admin.profile-meta.xml","name":"Admin"}]
[object Object]
An error occured during profile reconcile. You can rerun the command after a moment.
Worker stopped with exit code 1

busybox0 avatar Aug 03 '22 14:08 busybox0

Can you run it with trace flag?

genoud avatar Aug 03 '22 14:08 genoud

Not much more, here it is:

# sfdx sfpowerkit:source:profile:reconcile  -s --loglevel=trace
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.10 - Release:May 22
-------------------------------------------------------------------------------------------
ProfileList []
Project Directories ["resources","force-app","portals","profiles"]
Profiles Found in Project Directory 25
Initiated Profile reconcile thread :1  with a chunk of 1 profiles
Profiles queued in thread :1 :
[{"path":"profiles/profiles/Admin.profile-meta.xml","name":"Admin"}]
[object Object]
An error occured during profile reconcile. You can rerun the command after a moment.
Worker stopped with exit code 1

busybox0 avatar Aug 03 '22 14:08 busybox0

Taking a look at this linking issue today

Caitlyn-Mills avatar Aug 03 '22 23:08 Caitlyn-Mills

Thanks @Caitlyn-Mills @genoud Seems linking issue fixed and the initial bug is fixed too. I've linked it on node 14.18. License details were not removed with profile:reconcile -s.

busybox0 avatar Aug 08 '22 14:08 busybox0

Hi @Caitlyn-Mills @genoud
If the fix is ok from your side, can you please estimate when the released version with this fix may be available ? Thanks

busybox0 avatar Aug 09 '22 13:08 busybox0

Can this fix also be packed into upcoming release ? It works. Thanks.

busybox0 avatar Aug 22 '22 13:08 busybox0

We have pushed the fix in the 5.0.0 release. Thanks for raising the issue.

Caitlyn-Mills avatar Aug 31 '22 03:08 Caitlyn-Mills