port-labs / ocean

🌊 Ocean 🌊 is an innovative solution developed by Port to seamlessly integrate various third-party systems with our developer portal product, empowering engineers to effortlessly prioritize key features and streamline the integration process.
https://ocean.getport.io
Apache License 2.0
109 stars 39 forks source link

[Core] Fix resync issue when using `search identifier` in relation schema #890

Closed Tankilevitch closed 1 month ago

Tankilevitch commented 1 month ago

Description

What - Fixed resync issue when calculating the diff of entities failed due to search identifier in relation mapping Why - Calculating the entities diff was using the entity relations to map its relations and whether to delete it. When using search identifier feature the entity contained the search query rather than the actual relation of the entity after creation. How - Changed to use the entity created from port rather than the entity generated after JQ. Collecting the created entity returns the resulted relations identifiers that were generated for the entity.

Fixing:

> File "/usr/local/lib/python3.11/site-packages/port_ocean/core/event_listener/once.py", line 56, in resync_and_exit
    await self.events["on_resync"]({})
  File "/usr/local/lib/python3.11/site-packages/port_ocean/core/integrations/mixins/sync_raw.py", line 479, in sync_raw_all
    await self.entities_state_applier.delete_diff(
  File "/usr/local/lib/python3.11/site-packages/port_ocean/core/handlers/entities_state_applier/port/applier.py", line 94, in delete_diff
    await self._safe_delete(diff.deleted, kept_entities, user_agent_type)
  File "/usr/local/lib/python3.11/site-packages/port_ocean/core/handlers/entities_state_applier/port/applier.py", line 36, in _safe_delete
    related_entities = await get_related_entities(
  File "/usr/local/lib/python3.11/site-packages/port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py", line 45, in get_related_entities
    return [
  File "/usr/local/lib/python3.11/site-packages/port_ocean/core/handlers/entities_state_applier/port/get_related_entities.py", line 50, in <listcomp>
    for relation in set(relations)
Exception: unhashable type: 'dict'

Type of change

Please leave one option from the following and delete the rest:

Screenshots

Include screenshots from your environment showing how the resources of the integration will look.

API Documentation

Provide links to the API documentation used for this integration.