Skip to content
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

EnsureRecordType task failing with salesforce metadata api error #3826

Closed
leo-dcfa opened this issue Sep 10, 2024 · 5 comments
Closed

EnsureRecordType task failing with salesforce metadata api error #3826

leo-dcfa opened this issue Sep 10, 2024 · 5 comments
Labels

Comments

@leo-dcfa
Copy link
Contributor

Describe the bug

We use cci to manage multiple customer environments and one of the tasks we have is to ensure a certain record type exists. This task works for 60+ orgs but fails for one of them:

tasks:
    ensure_event_record_type:
        class_path: cumulusci.tasks.salesforce.EnsureRecordTypes
        options:
            record_type_developer_name: Event_Ticket
            record_type_label: Event Ticket
            sobject: Opportunity
            force_create: True

The task works in all orgs except for one, it fails with:

[09/09/24 09:02:36] Org info updated, writing to keychain                                                                                                                                                                                                                                                                                                                                                                        
                    Beginning task: Deploy                                                                                                                                                                                                                                                                                                                                                                                       
                    As user: {ommitted}                                                                                                                                                                                                                                                                                                                                                                             
                    In org: {ommitted}                                                                                                                                                                                                                                                                                                                                                                                   
                    Cleaning meta.xml files of packageVersion elements for deploy                                                                                                                                                                                                                                                                                                                                                
                    Payload size: 896 bytes                                                                                                                                                                                                                                                                                                                                                                                      
                    Pending                                                                                                                                                                                                                                                                                                                                                                                                      
                    [Pending]: next check in 1 seconds                                                                                                                                                                                                                                                                                                                                                                           
[09/09/24 09:02:38] [Done]                                                                                                                                                                                                                                                                                                                                                                                                       
[09/09/24 09:02:39] [Failed]: Update of CustomObject Opportunity: Error on line 7, col 33: Error parsing file: The entity name must immediately follow the '&' in the entity reference.                                                                                                                                                                                                                                          
Error: Could not process MDAPI response: Update of CustomObject Opportunity: Error on line 7, col 33: Error parsing file: The entity name must immediately follow the '&' in the entity reference.
Run this command for more information about debugging errors: cci error --help

Reproduction steps

Run cci task against specific org; otherwise unable to reproduce in other orgs

Your CumulusCI and Python versions

cci: 3.91.0
python version: 3.10.0

Operating System

macOS

Windows environment

No response

CumulusCI installation method

None

Error Gist

https://gist.github.com/leo-dcfa/20e05c1a2981dd04df3b6f64de1db9cc

Additional information

No response

@leo-dcfa leo-dcfa added the bug label Sep 10, 2024
@jstvz
Copy link
Contributor

jstvz commented Sep 11, 2024

Thanks for the report, @leo-dcfa. This task isn't sanitizing XML, so I think that's the likely culprit. Does the affected org have a picklist value on StageName that contains an ampersand (&)?

@leo-dcfa
Copy link
Contributor Author

@jstvz you are right, Identify & Qualify is a value. Seems like an easy fix - I'm happy to tackle it, Python is my most used language. Do we have a preferred way of escaping characters?

@jstvz
Copy link
Contributor

jstvz commented Sep 12, 2024

Thanks, @leo-dcfa! You can use xml.sax.saxutils.escape from the stdlib. For example, see:

def _build_envelope_start(self):
return self.soap_envelope_start.format(
name=escape(self.name),
description=escape(self.description),
license_id=escape(self.license_id),
)

@leo-dcfa
Copy link
Contributor Author

@jstvz
Copy link
Contributor

jstvz commented Sep 23, 2024

Fixed by #3827

@jstvz jstvz closed this as completed Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants