sfpowerkit icon indicating copy to clipboard operation
sfpowerkit copied to clipboard

profile:retrieve followed by profile:merge or profile:reconcile gives delta when run against the same org

Open busybox0 opened this issue 2 years ago • 10 comments

Edit after few days: there are at least 2 very similar issues. Added Part 2 into this one.

Part 1.

sfpowerkit:source:profile:retrieve followed by sfpowerkit:source:profile:merge gives delta when run against the same org

To Reproduce

sfdx sfpowerkit:source:profile:retrieve -n Admin -u user1
git add .  # saving state of fully retrieved profile
sfdx sfpowerkit:source:profile:merge -n Admin -u user1  # some extra tab visibilities appeared

Diff shows some amount of standard tabs appeared in profile (list is not full, there are more than these).

    <tabVisibilities>
        <tab>standard-AccountBrand</tab>
        <visibility>Hidden</visibility>
    </tabVisibilities>
    <tabVisibilities>
        <tab>standard-ActiveScratchOrg</tab>
        <visibility>DefaultOff</visibility>
    </tabVisibilities>
    <tabVisibilities>
        <tab>standard-AnalyticsDataManager</tab>
        <visibility>DefaultOn</visibility>
    </tabVisibilities>

Expected behavior output of sfpowerkit:source:profile:merge should be the same as we just retrieved the full version with sfpowerkit:source:profile:retrieve.

Part 2.

sfpowerkit:source:profile:reconcile -n Admin -u user1 removes some fieldPermissions, classAccesses, layoutAssignments, objectPermissions, recordTypeVisibilities from the profile retrieved seconds before with sfpowerkit:source:profile:retrieve -n Admin -u user1

Here are examples of what was removed by sfpowerkit:source:profile:reconcile -u user1 (list is not full)

        <apexClass>LID__TaskUpdateBatch</apexClass>
        <field>Case.ClosedOnCreate</field>
        <layout>ActiveScratchOrg-Active Scratch Org Layout</layout>
        <layout>ScratchOrgInfo-Scratch Org Info Layout</layout>
        <object>SocialPersona</object>
        <recordType>Idea.InternalIdeasIdeaRecordType</recordType>

Expected behavior output of sfpowerkit:source:profile:reconcile should be the same as we just retrieved the full version with sfpowerkit:source:profile:retrieve.

Desktop:

  • OS: WSL Ubuntu / Windows
  • sfdx-cli/7.154.0 wsl-x64 node-v14.17.6
  • Version of sfpowerkit 4.2.8

busybox0 avatar Jul 01 '22 11:07 busybox0

Another day shows another results, today the situation is following: sfpowerkit:source:profile:reconcile -n Admin -u user1 removes some fieldPermissions form the profile retrieved seconds before with sfpowerkit:source:profile:retrieve -n Admin -u user1

Note all actions are against the same org. Some of fields, removed:

<fieldPermissions>
    <editable>false</editable>
    <field>Case.ClosedOnCreate</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>ContactPointConsent.ContactPointTypeConsentId</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>DataUsePurpose.IsMaintainablePerContactPoint</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>DataUsePurpose.IsMaintainablePerParty</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>DataUsePurpose.IsMaintainablePerType</field>
    <readable>true</readable>
</fieldPermissions>

busybox0 avatar Jul 04 '22 10:07 busybox0

Another day shows another results, today the situation is following: sfpowerkit:source:profile:reconcile -n Admin -u user1 removes some fieldPermissions form the profile retrieved seconds before with sfpowerkit:source:profile:retrieve -n Admin -u user1

Note all actions are against the same org. Some of fields, removed:

<fieldPermissions>
    <editable>false</editable>
    <field>Case.ClosedOnCreate</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>ContactPointConsent.ContactPointTypeConsentId</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>DataUsePurpose.IsMaintainablePerContactPoint</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>DataUsePurpose.IsMaintainablePerParty</field>
    <readable>true</readable>
</fieldPermissions>
<fieldPermissions>
    <editable>true</editable>
    <field>DataUsePurpose.IsMaintainablePerType</field>
    <readable>true</readable>
</fieldPermissions>

Confirming similar results on "retrieve vs. reconcile": In a developer org, I retrieved Admin profile and reconciled it againsts the same org using System Adminstrator user.

sfdx sfpowerkit:source:profile:retrieve  -f "src-temp/main/default/profiles" -n Admin -u OrgShapeTest
 »   Warning: sfdx-cli update available from 7.149.1 to 7.154.0.
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.5 - Release:April 22
-------------------------------------------------------------------------------------------
Number of profiles to retrieve 1
Loading profiles in batches  - PROGRESS  | ████████████████████████████████████████ | 1/1  Profiles
State    Full Name  Type     Path
───────  ─────────  ───────  ─────────────────────────────────────────────────────
Updated  Admin      Profile  src-temp\main\default\profiles\Admin.profile-meta.xml
sfdx sfpowerkit:source:profile:reconcile -f "src-temp/main/default/profiles" -n Admin -u OrgShapeTest
 »   Warning: sfdx-cli update available from 7.149.1 to 7.154.0.
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.5 - Release:April 22
-------------------------------------------------------------------------------------------
Profiles Found in Project Directory 1
Initiated Profile reconcile thread :1  with a chunk of 1 profiles
Profiles queued in thread :1 :
[{"path":"src-temp\\main\\default\\profiles\\Admin.profile-meta.xml","name":"Admin"}]
Reconciled Profile src-temp\main\default\profiles\Admin.profile-meta.xml
State    Full Name  Type     Path
───────  ─────────  ───────  ─────────────────────────────────────────────────────
Cleaned  Admin      Profile  src-temp\main\default\profiles\Admin.profile-meta.xml

The XML file has been decrerased approx. by 1,300 lines. Some of the lines that have been removed:

    <tabVisibilities>
        <tab>standard-WorkPlan</tab>
        <visibility>DefaultOn</visibility>
    </tabVisibilities>
    <tabVisibilities>
        <tab>standard-WorkPlanTemplate</tab>
        <visibility>DefaultOn</visibility>
    </tabVisibilities>
    <tabVisibilities>
        <tab>standard-WorkStepTemplate</tab>
        <visibility>DefaultOn</visibility>
    </tabVisibilities>
    <tabVisibilities>
        <tab>standard-WorkType</tab>
        <visibility>DefaultOn</visibility>
    </tabVisibilities>
    <tabVisibilities>
        <tab>standard-WorkTypeGroup</tab>
        <visibility>DefaultOn</visibility>
    </tabVisibilities>
    <tabVisibilities>
    <objectPermissions>
        <allowCreate>true</allowCreate>
        <allowDelete>true</allowDelete>
        <allowEdit>true</allowEdit>
        <allowRead>true</allowRead>
        <modifyAllRecords>true</modifyAllRecords>
        <object>FinanceTransaction</object>
        <viewAllRecords>true</viewAllRecords>
    </objectPermissions>
    <objectPermissions>
        <allowCreate>true</allowCreate>
        <allowDelete>true</allowDelete>
        <allowEdit>true</allowEdit>
        <allowRead>true</allowRead>
        <modifyAllRecords>true</modifyAllRecords>
        <object>GtwyProvPaymentMethodType</object>
        <viewAllRecords>true</viewAllRecords>
    </objectPermissions>

AndreyShestakovACN avatar Jul 04 '22 13:07 AndreyShestakovACN

Edited the initial issue body. Added Part 2.

busybox0 avatar Jul 04 '22 14:07 busybox0

Thanks for raising this @busybox0 - We will look into it.

Caitlyn-Mills avatar Jul 04 '22 23:07 Caitlyn-Mills

I was able to reproduce this. Will push a fix for it.

genoud avatar Jul 17 '22 23:07 genoud

Hello @genoud, thanks for taking a look. I've linked plugin from this branch, though it fails.

sfdx plugins
sfpowerkit 4.2.10 (link) C:\projects\sfpowerkit
cd sfpowerkit
git log -1
commit 84a0d88a9727a5e8592c1b644b061560c1bacfd9 (HEAD -> issue/694, origin/issue/694)
...
cd projects/my_project
sfdx sfpowerkit:source:profile:reconcile -n Admin -u user1 --loglevel=TRACE
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.10 - Release:May 22
-------------------------------------------------------------------------------------------
ProfileList ["Admin"]
Project Directories ["resources","force-app","portals","profiles"]
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 Jul 27 '22 14:07 busybox0

Hello @genoud, thanks for taking a look. I've linked plugin from this branch, though it fails.

sfdx plugins
sfpowerkit 4.2.10 (link) C:\projects\sfpowerkit
cd sfpowerkit
git log -1
commit 84a0d88a9727a5e8592c1b644b061560c1bacfd9 (HEAD -> issue/694, origin/issue/694)
...
cd projects/my_project
sfdx sfpowerkit:source:profile:reconcile -n Admin -u user1 --loglevel=TRACE
-------------------------------------------------------------------------------------------
sfpowerkit  -- The DX@Scale Developer Toolkit - Version:4.2.10 - Release:May 22
-------------------------------------------------------------------------------------------
ProfileList ["Admin"]
Project Directories ["resources","force-app","portals","profiles"]
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

@azlam-abdulsalam linking issue

Caitlyn-Mills avatar Jul 29 '22 00:07 Caitlyn-Mills

Hi @Caitlyn-Mills

I'm not facing this issue on my end. Can you try the solution 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

Linking issue has been resolved now.

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

Hi @genoud, the first part of the issue is fixed, thanks. Though, the 2nd part where following sequence is run, is not fixed.

sfdx sfpowerkit:source:profile:retrieve  -n Admin -u user1
git add .
sfdx sfpowerkit:source:profile:reconcile -n Admin -u user1

It still removes a lot of stuff from profile as described above.

busybox0 avatar Aug 08 '22 16:08 busybox0

Thanks @busybox0 - I have tested and yes correct the first issue is solved and I can replicate that the 2nd issue still exists. I'm going to close this issue when we do our August release with the fix, and have a separate issue for the 2nd part.

Caitlyn-Mills avatar Aug 17 '22 00:08 Caitlyn-Mills

Great, thanks @Caitlyn-Mills

busybox0 avatar Aug 22 '22 13:08 busybox0

We have pushed the fix for the first issue in 5.0.0 and raised a new issue for the second https://github.com/dxatscale/sfpowerkit/issues/730

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