Skip to content

Commit f4d8942

Browse files
committed
Update get_resources_by_batch to return partial results instead of 404 when resources are not found.
1 parent 19a51f7 commit f4d8942

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ GET /api/resources/find-resources-in-batch?id=riscv-ubuntu-20.04-boot&resource_v
5353

5454
- Each `id` parameter must have a corresponding `resource_version` parameter
5555
- Use `resource_version=None` to retrieve all versions of a resource
56-
- Returns 404 if any requested resource is missing
56+
- Returns a list of resources that were found even if not all requested resources were found.
57+
- Returns an empty list is no resources were found.
5758

5859
### 2. Advanced Resource Search
5960

functions/get_resources_by_batch.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,6 @@ def find_resources_in_batch(req: func.HttpRequest) -> func.HttpResponse:
8080
collection.find({"$or": queries}, RESOURCE_FIELDS)
8181
)
8282

83-
# Check if any resources were found
84-
if not resources:
85-
return create_error_response(
86-
404, "No requested resources were found"
87-
)
88-
89-
# Check if at least one instance of each requested ID is present
90-
found_ids = {resource.get("id") for resource in resources}
91-
missing_ids = set(ids) - found_ids
92-
93-
if missing_ids:
94-
return create_error_response(
95-
404,
96-
"The following requested resources were not found: "
97-
f"{', '.join(missing_ids)}",
98-
)
99-
10083
return func.HttpResponse(
10184
body=json.dumps(resources),
10285
status_code=200,

0 commit comments

Comments
 (0)