Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Unable to process Picklist update due to Cannot read properties of undefined (reading 'Metadata') #1441

Closed
cjbradshaw opened this issue Nov 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cjbradshaw
Copy link
Contributor

Describe the bug
A followup bug to #1414
the picklist deployer fails when the picklist doesn't exist in the target org. It continues to attempt to read the child attributes even though it's undefined.
example log message :
Fetching picklist for custom field Sync_To__c on object Account
Unable to process Picklist update due to Cannot read properties of undefined (reading 'Metadata')

To Reproduce
add a new picklist to an object. Run a through validation job or deployment job if packaged.
Ensure the package definition doesn't include "enablePicklist": false (its enabled by default)

I think line 78 in packages/core/src/package/deploymentCustomizers/PicklistEnabler.ts is where the issue is

I believe the logic wants to be along the lines of picklistInOrg is null or the valueSetDefinition of the picklist is null then continue but this doesn't evaluate correctly as is. picklistInOrg is undefined when the picklst doesn't exist in target.
I made the following change locally which worked better for me. Happy to raise the PR

FROM
if (!picklistInOrg && picklistInOrg?.Metadata?.valueSet?.valueSetDefinition) continue;

TO
if (!picklistInOrg?.Metadata?.valueSet?.valueSetDefinition){
sfp_logger_1.default.log('picklist not in Org',sfp_logger_1.LoggerLevel.TRACE,logger);
continue;
}

Expected behavior
When it gets to processing the Picklists (PicklistEnabler) it will fail with a message like :
Unable to process Picklist update due to Cannot read properties of undefined (reading 'Metadata')

Screenshots
If applicable, add screenshots to help explain your problem.

Platform Details (please complete the following information):

  • OS: MacOS
  • Version [e.g. CLI Version eg: 1.6.6] SFP version 25.0.6
  • Salesforce CLI(sfdx cli) Version: SF version 2.7.11
  • CI Platform: GithubAction

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added the analysis To be decided on how to solution/fix label Nov 20, 2023
@azlam-abdulsalam
Copy link
Contributor

Thanks @cjbradshaw for the detailed analysis, can you raise a PR please

@azlam-abdulsalam azlam-abdulsalam added bug Something isn't working and removed analysis To be decided on how to solution/fix labels Nov 21, 2023
@azlam-abdulsalam azlam-abdulsalam added this to the December 23 milestone Nov 21, 2023
@azlam-abdulsalam
Copy link
Contributor

This is been resolved and fixed in December release

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants