Skip to content

Commit

Permalink
Fix the required fields error for the Upsert action (#3817)
Browse files Browse the repository at this point in the history
Suppress the required field check for the upsert action at mappingstep

---------

Co-authored-by: aditya-balachander <[email protected]>
  • Loading branch information
lakshmi2506 and aditya-balachander committed Aug 20, 2024
1 parent b6d0c38 commit d3676b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
5 changes: 2 additions & 3 deletions cumulusci/tasks/bulkdata/mapping_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 20 additions & 10 deletions cumulusci/tasks/bulkdata/tests/test_mapping_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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):
Expand Down

0 comments on commit d3676b4

Please sign in to comment.