Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core] JQ Mapping log enrichment - empty values support (#1285)
# Description What - added test and support for use-case of empty string of identifier/blueprint values, added debug log to validate the identifier and blueprint values Why - I've identified that there are 2 main use-cases for us to log the details about, for null, missing and / or mis configured values AND for empty strings. the empty string is not a "wrong / misconfigured" value for JQ, but it is a non valid identifier. current logs were missing this details and were not clear enough also added example on how to assert on logs How - added tests and validations following logs investigations ``` raw_results: list[dict[Any, Any]] = [ {"foo": "", "bar": "bluePrintMapped"}, {"foo": "identifierMapped", "bar": ""}, ] result = await mocked_processor._parse_items(mapping, raw_results) assert "identifier" not in result.misonfigured_entity_keys assert "blueprint" not in result.misonfigured_entity_keys raw_results = [ {"foo": "identifierMapped", "bar": None}, {"foo": None, "bar": ""}, ] result = await mocked_processor._parse_items(mapping, raw_results) assert result.misonfigured_entity_keys == { "identifier": ".foo", "blueprint": ".bar", } ``` tests now pass values with empty strings and None, tests validate proper logs and make sure to output the relevant details with an additional counter for the empty values. expected to see a batch of 100 with 65 empty values and only 35 upserted. new logs text example (picture below): ``` port_ocean/tests/core/handlers/entity_processor/test_jq_entity_processor.py::TestJQEntityProcessor::test_parse_items_empty_required 2025-01-01 15:54:09.083 | INFO | port_ocean.core.handlers.entity_processor.jq_entity_processor:_parse_items:256 - Parsing 2 raw results into entities 2025-01-01 15:54:09.083 | DEBUG | port_ocean.utils.queue_utils:_start_processor_worker:21 - Processing async task 2025-01-01 15:54:09.084 | DEBUG | port_ocean.utils.queue_utils:_start_processor_worker:21 - Processing async task 2025-01-01 15:54:09.088 | DEBUG | port_ocean.core.handlers.entity_processor.jq_entity_processor:_parse_items:267 - Finished parsing raw results into entities with 0 errors. errors: [] 2025-01-01 15:54:09.089 | INFO | port_ocean.core.handlers.entity_processor.jq_entity_processor:_log_mapping_issues_identified:88 - 2 transformations of batch failed due to empty values 2025-01-01 15:54:09.089 | INFO | port_ocean.core.handlers.entity_processor.jq_entity_processor:_parse_items:256 - Parsing 2 raw results into entities 2025-01-01 15:54:09.089 | DEBUG | port_ocean.utils.queue_utils:_start_processor_worker:21 - Processing async task 2025-01-01 15:54:09.089 | DEBUG | port_ocean.utils.queue_utils:_start_processor_worker:21 - Processing async task 2025-01-01 15:54:09.090 | DEBUG | port_ocean.core.handlers.entity_processor.jq_entity_processor:_parse_items:267 - Finished parsing raw results into entities with 0 errors. errors: [] 2025-01-01 15:54:09.090 | DEBUG | port_ocean.core.handlers.entity_processor.jq_entity_processor:_parse_items:298 - Transformation failed, values verification for identifier: identifierMapped, for blueprint: None 2025-01-01 15:54:09.090 | INFO | port_ocean.core.handlers.entity_processor.jq_entity_processor:_log_mapping_issues_identified:84 - Unable to find valid data for: {'blueprint': '.bar', 'identifier': '.foo'} (null, missing, or misconfigured) 2025-01-01 15:54:09.090 | INFO | port_ocean.core.handlers.entity_processor.jq_entity_processor:_log_mapping_issues_identified:88 - 1 transformations of batch failed due to empty values ``` ![Screenshot 2025-01-01 at 15 54 16](https://github.com/user-attachments/assets/d3f886a2-5d81-416c-81bd-3ed772c35b50) ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) --------- Co-authored-by: Arik Gortsunian <[email protected]>
- Loading branch information