Fixing Profiles #1785
Replies: 11 comments 25 replies
-
First off, thank you for giving this some much needed (and LONG overdue) attention! I can't tell you how many times I've had to explain to my IC2 users how authorization metadata retrieval works and how to work around the behavior. And even then it can be extremely cumbersome because adding all of the necessary metadata to the same request can be difficult...or they just punt and perform a full metadata retrieval to cover all the bases. The proposed solution seems like it would work well. IC2 uses the CLI for all retrievals in source format projects, and I'll be happy to expose the new option (defaulted to enabled!) for configuration if there's someone out there who wants the old behavior. I might even consider implementing this approach in IC2's native metadata retriever for folks using metadata format projects. Certainly feel free to let me know when you have a working version so I can create a first-pass integration and provide any feedback as a tooling consumer. |
Beta Was this translation helpful? Give feedback.
-
I was trying to figure out why I never have this problem on Perm Sets, though I'm very familiar with it on Profiles.
The only other note I have is there are other metadata types with this same behavior, Translations being the one that comes to mind. I don't push/pull many profiles via SFDX and have them on |
Beta Was this translation helpful? Give feedback.
-
I like the entry inside For other options, if developer 1 uses the flag whereas developer 2 doesn't, that would not work as profiles could still become invalid at some point. Moreover, as this seems to be implement as a low level option, this would also work whereas we're using the command line or VS Code command palette. Beside hooks being broken, the reason I don't use them anymore is that they are not firing if using the command palette. Looking forward to it ! |
Beta Was this translation helpful? Give feedback.
-
I've had a few conversations with @jayree and he's shown me a few issues he's found when using the tooling api and querying There are also problem with getting the correct He's spent a lot of time working with these two types, and has authored plugins that will help this scenario. He pointed me to a few different methods that he's written to work around these limitations there
Cc: @mshanemc |
Beta Was this translation helpful? Give feedback.
-
Hi @FabienTaillon @jayree @ImJohnMDaniel @SCWells72 @aheber I've got the first pass of enhancing Check out the demo below: I think I ended the demo one command too early, if I ran Given the two issues of
Would you still like to see this optional functionality added? |
Beta Was this translation helpful? Give feedback.
-
I've been dealing with some pain around this for a few months. I'm in the middle of a [uh, I need a color between brown and green....]-field project that's merging 2 orgs into a clean 3rd, and as part of the shift, has moved away from granting permissions in profiles. So while there are nice options for fixing profiles today, the bigger need and the clear direction SF is going is permission sets. I'm not opposed to finding a quick-win for profiles like the various plugins mentioned earlier here, but we absolutely can't stop there and shrug and say good enough. I've been working out of a full copy and production org, trying to get everything migrated from the FC to Production, so source tracking based options aren't applicable, though we do have it enabled in our production org, the dev sandboxes are currently so old that the feature was enabled in production after their last refresh, so that's not helping. If we think about "lowering the barrier to entry" or "reducing unpleasant surprises" when using the CLI, it seems like a logical default would be to have the default behavior pull the entire profile / permission set, while giving the option to override. For that, I like both the project json option -- can be git tracked and easy to just set once and never deal with again, and the CLI switch to override for a single command execution (this option may also be helpful to 3rd parties who develop tooling on top of the CLI where you don't want to rewrite a customer's git repo). |
Beta Was this translation helpful? Give feedback.
-
How is using the Tooling API different from using the CRUD Metadata API (Read)? There's a project that already solves this problem https://github.com/amtrack/sfdx-plugin-source-read |
Beta Was this translation helpful? Give feedback.
-
@azlam-abdulsalam we have been using your (ACN) plugin (sfpowerkit) and it works like a charm (lifesaver) for full profile retrieve but somehow reconcile and merge aren't that well supported (may be due to some dependencies), i myself am working on a Custom solution. Many times I feel developers don't use force:source:tracking:reset as a good settler. There are many plugins that solve the problem which we are trying to address here unless there is a scalability and a vision roadmap because in one way or the other there is no robust one without workarounds It's essential to write Gherkin and streamline the milestones. |
Beta Was this translation helpful? Give feedback.
-
Yeah a simple find/replace in VSCode takes care of it.
…On Thu, Dec 22, 2022 at 6:37 PM Pablo Gonzalez ***@***.***> wrote:
How do you remove them? Manually?
—
Reply to this email directly, view it on GitHub
<#1785 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3OVKADSSMYLU5MQMPAF2VLWOTQ5BANCNFSM6AAAAAARUPJSUE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
We need the same approach for CustomLabels and Translations. Consider both the first retrieve operation and well as subsequent retrieves, whether metadata has been added or deleted in the meantime. When you deploy labels, we need to make sure that multiple label files in the same force-app folder structure do not contain the same label with different values. All this also applies to translations. |
Beta Was this translation helpful? Give feedback.
-
Hey Everyone 👋 After a discussion with the team we've decided to halt working on this feature. We came to this conclusion for a few reasons...
While we know this news will always be disappointing to hear, we hope you understand. Thanks for being a part of the CLI Community ❤️ 🚀 |
Beta Was this translation helpful? Give feedback.
-
Background
The CLI uses the metadata API for retrieves. Profiles and Permission Sets have the following special behavior—unlike normal metadata type, the API will return a subset of a profile that corresponds to other members of the retrieve request.
Example:
Object__c
has fieldField__c
on it.myProfile
grants access to the object and field with the followingIf I retrieve the Profile and also retrieve the Object and Field the Profile will contain the corresponding
fieldPermissions
andobjectPermissions
entriesIf I retrieve the Profile without retrieving the Object and Field the Profile won’t contain those entries.
That’s on regular orgs and sandboxes that don’t support source tracking.
What happens on scratch orgs and tracking sandboxes? We return the Profile containing objects/field that have SourceMembers associated with them (that is, they’ve changed)
This is usually “pretty close” since it’s tracking modifications and return full-ish profiles from those orgs
Problem
Now, consider what this user is doing #1396 (also #1624)
They update the Description on the Profile in the org, and want to pull that down.
sfdx force:source:pull
will return a profile with no object/field permissions (since only the Profile has changed) and then it writes the Profile with all of those removed from their local version ofmyProfile
.But, it’s also impossible to say that the user didn’t remove that Object/Field from the Profile. Simply “merging” the missing xml would prevent the user from removing that permission intentionally (which is common when transition from Profiles to PermSets)
This isn’t specific to tracking commands, either. You could do
sfdx force:source:retrieve -m Profile:myProfile
and also see it remove all of those entries.If you’re retrieving from a non-tracking org, you won’t get full profiles.
Current State
We normally recommend that customers ignore Profiles (via
.forceignore
) and prefer PermissionSet for dealing with permissions—even though those are subject to the same restriction (will omit parts when not retrieved with those items)Salesforce, however, still focuses users on Profiles (ex: the field creation wizard always asks which profiles, and has some of them checked by default, so users have to manually remove them each time) Customers do workarounds for these—one of the real-world uses of preretrieve hooks for Fabien/Texei was to look through the local copy of any Profile in a retrieve and patch the retrieve manifest with all the field/object/classes mentioned so that the retrieved Profile would be complete. But We Broke deploy/retrieve hooks . They could still have a hook that runs AFTER the main retrieve/pull and does a 2nd retrieve to get the full profile.
Location
Inside SDR, divert profile retrieves to the tooling API, which does retrieve the complete profile. You can verify this with
sfdx
,sf
, VSCode, second-party plugins, other SDR consumers)How should we enable this ❓
As #4 explains above, this new functionality should be optional. We know you have built processes and tools around current behavior and would hate to break those so we'll be gating this functionality behind a few different options that we'd love your feedback on:
sfdx
config value/environment variable (default: false): this would allow users to adopt this new behavior as they see fitsfdx
flag onretrieve
/pull
(default:false): this would allow you to have this new behavior on a per command basis, but be able to use the new functionality easily when they wantsf
config value/environment variable (default: true): this would enable this new and more consistent behavior for thesf
cli, so as you transition you'll see more and more improvements oversfdx
sf
flagsf metadata retrieve
(default:true): would allow you to specify--incompleteProfileRetrieve
(we would come up with a more succinct and descriptive name) but this would allow you to maintain backwards compatibility between thesf
andsfdx
cli.sfdx-project.json
(default: false): this would give the same benefits as asfdx
config value, but also allow teams to adopt new behavior at the same time and create a consistent developer experience. We could also enable this behavior for new projects created withforce:project:create
How would you like to see this implemented? Are there any other metadata types that fit into this category that should be included in a parallel retrieve? Is there anything we've missed, would you like to see something else added to this? Let's discuss!
❤️ the CLI team.
Beta Was this translation helpful? Give feedback.
All reactions