dance-engine / dance-engine/the-engine

Always return lists if something that could be a list

Open
#38 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

the `query_gsi()` function currently returns different things depending on what is being asked, the main buggy problem is when getting something where you expect more than one item but it might only be one item and it currently **returns just that item instead of list with one item**.

This is currently temporarily fixed in both `lambda_items` and `lambda_bundles` with a hotfix:

```
#! temporary fix this needs review
if len(items) == 1:
items = [items]
```

Hot fix is needed because in these lambdas the response model expects a list of the object in any case.

In older lambdas like `lambda_events` their is two behaviours one for getting an event and getting all events with different response structures - this needs fixing too.

---
The problem code in `query_gsi()` is line 95:

```
91 logger.info(f"Fetched {len(items)} from dynamodb: {items}")
92 if assemble_entites:
93 return self.assemble_from_items(items)
94 else:
95 return [self.model_validate(item) for item in items] if len(items) > 1 else self.model_validate(items[0])
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.