Skip to content

Commit d8c64a3

Browse files
committed
fix: return unsupported task type when no task_type match
Signed-off-by: habeck <habeck@us.ibm.com>
1 parent 296f22e commit d8c64a3

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

cpex/framework/isolated/worker.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ async def process_task(task_data, tp: TaskProcessor):
142142
violations_as_exceptions=False,
143143
)
144144
return result
145+
return {
146+
"status": "error",
147+
"message": "task type not supported.",
148+
"request_id": task_data.get("request_id", "unknown") if "task_data" in locals() else "unknown",
149+
}
145150

146151

147152
async def main():
@@ -179,7 +184,7 @@ async def main():
179184
# Serialize response
180185
if response:
181186
serializable_response = response.model_dump(mode="json")
182-
else:
187+
else: # none case should be a failure rather than success.
183188
serializable_response = {"status": "success"}
184189

185190
# Add request_id to response

tests/unit/cpex/framework/isolated/test_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async def test_process_task_unknown_task_type(self):
245245
tp = TaskProcessor()
246246
# Should return None or handle gracefully
247247
result = await process_task(task_data, tp)
248-
assert result is None
248+
assert result == {'message': 'task type not supported.', 'request_id': 'unknown', 'status': 'error'}
249249

250250
@pytest.mark.asyncio
251251
@patch("cpex.framework.isolated.worker.get_proper_config")

0 commit comments

Comments
 (0)