From d3676b4e8afe5a646647b8db1a600ae74aaffdc7 Mon Sep 17 00:00:00 2001 From: lakshmi2506 <141401869+lakshmi2506@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:25:17 +0530 Subject: [PATCH] Fix the required fields error for the Upsert action (#3817) Suppress the required field check for the upsert action at mappingstep --------- Co-authored-by: aditya-balachander --- cumulusci/tasks/bulkdata/mapping_parser.py | 5 ++-- .../bulkdata/tests/test_mapping_parser.py | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cumulusci/tasks/bulkdata/mapping_parser.py b/cumulusci/tasks/bulkdata/mapping_parser.py index 3e6aa28541..bb59fc6647 100644 --- a/cumulusci/tasks/bulkdata/mapping_parser.py +++ b/cumulusci/tasks/bulkdata/mapping_parser.py @@ -554,9 +554,8 @@ def strip(element: str): ) if is_load: - required_fields_correct = self.check_required(describe) - if not required_fields_correct: - return False + # Show warning logs for unspecified required fields + self.check_required(describe) if not (fields_correct and lookups_correct): return False diff --git a/cumulusci/tasks/bulkdata/tests/test_mapping_parser.py b/cumulusci/tasks/bulkdata/tests/test_mapping_parser.py index 1ad4476976..c1419f300b 100644 --- a/cumulusci/tasks/bulkdata/tests/test_mapping_parser.py +++ b/cumulusci/tasks/bulkdata/tests/test_mapping_parser.py @@ -1104,7 +1104,10 @@ def test_validate_and_inject_mapping_throws_exception_required_lookup_dropped(se ) @responses.activate - def test_validate_and_inject_mapping_throws_exception_required_fields_missing(self): + def test_validate_and_inject_mapping_throws_exception_required_fields_missing( + self, caplog + ): + caplog.set_level(logging.ERROR) mock_describe_calls() mapping = parse_from_yaml( StringIO( @@ -1117,15 +1120,22 @@ def test_validate_and_inject_mapping_throws_exception_required_fields_missing(se {"instance_url": "https://example.com", "access_token": "abc123"}, "test" ) - with pytest.raises(BulkDataException): - validate_and_inject_mapping( - mapping=mapping, - sf=org_config.salesforce_client, - namespace=None, - data_operation=DataOperationType.INSERT, - inject_namespaces=False, - drop_missing=False, - ) + validate_and_inject_mapping( + mapping=mapping, + sf=org_config.salesforce_client, + namespace="", + data_operation=DataOperationType.INSERT, + inject_namespaces=False, + drop_missing=False, + ) + + expected_error_message = ( + "One or more required fields are missing for loading on Account :{'Name'}" + ) + error_logs = [ + record.message for record in caplog.records if record.levelname == "ERROR" + ] + assert any(expected_error_message in error_log for error_log in error_logs) @responses.activate def test_validate_and_inject_mapping_injects_namespaces(self):