Skip to content

Commit

Permalink
Fixed error in register_raw when there's no relevant mappings for a s…
Browse files Browse the repository at this point in the history
…pecific kind (#596)

# Description

What - Fixed error in register_raw when there's no relevant mappings for
a specific kind:
```
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/tasks.py", line 267, in __step
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "/Users/omribarouch/Desktop/ocean/integrations/gitlab/gitlab_integration/events/hooks/base.py", line 37, in on_hook
    await self._on_hook(body, project)
  File "/Users/omribarouch/Desktop/ocean/integrations/gitlab/gitlab_integration/events/hooks/merge_request.py", line 20, in _on_hook
    await ocean.register_raw(ObjectKind.MERGE_REQUEST, [merge_requests.asdict()])
  File "/Users/omribarouch/Desktop/ocean/port_ocean/context/ocean.py", line 105, in register_raw
    await self.integration.register_raw(kind, change, user_agent_type)
  File "/Users/omribarouch/Desktop/ocean/port_ocean/core/integrations/mixins/sync_raw.py", line 229, in register_raw
    registered_entities, entities_to_delete = zip_and_sum(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)
```
This is happened to me when received merge request webhook from the
gitlab integration, while the merge request mapping isn't created by
default in the integration so the diffs object in
`port_ocean/core/integrations/mixins/sync_raw.py` line 22 is empty

## Type of change

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

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] New Integration (non-breaking change which adds a new integration)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Non-breaking change (fix of existing functionality that will not
change current behavior)
- [ ] Documentation (added/updated documentation)

## 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.

---------

Co-authored-by: Yair Siman Tov <63305203+yairsimantov20@users.noreply.github.com>
  • Loading branch information
omby8888 and yairsimantov20 committed Apr 30, 2024
1 parent e8f377c commit 6a1a43d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

<!-- towncrier release notes start -->

## 0.5.15 (2024-04-30)

### Bug Fixes

- Fixed error in `register_raw` when there's no relevant mappings for a specific kind


## 0.5.14 (2024-04-24)

### Improvements
Expand Down
3 changes: 3 additions & 0 deletions port_ocean/core/integrations/mixins/sync_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ async def register_raw(
resource for resource in config.resources if resource.kind == kind
]

if not resource_mappings:
return []

diffs: list[EntitySelectorDiff] = await asyncio.gather(
*(
self._register_resource_raw(resource, results, user_agent_type, True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "port-ocean"
version = "0.5.14"
version = "0.5.15"
description = "Port Ocean is a CLI tool for managing your Port projects."
readme = "README.md"
homepage = "https://app.getport.io"
Expand Down

0 comments on commit 6a1a43d

Please sign in to comment.