aws-samples / aws-samples/sample-finops-agent
Standardize error response format in test Lambda function
- Dominant language
- Python
- Stars
- 14
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
The test Lambda function (`src/lambda/mcp_servers/test/lambda_function.py`) uses inconsistent response formats:
**Error responses** return HTTP-style objects:
```python
return {"statusCode": 400, "body": json.dumps({"error": "message parameter is required"})}
return {"statusCode": 404, "body": json.dumps({"error": f"Unknown tool: {tool_name}", ...})}
```
**Success responses** return plain dicts:
```python
return {"message": f"Hello, {name}!", ...}
```
Other MCP Lambda functions (`athena`, `cost_explorer`, `cur_analyst`) consistently return plain dicts for both success and error:
```python
return {"error": str(e)} # errors
return {"results": [...]} # success
```
## Expected Behavior
The test Lambda should follow the same pattern as other MCP Lambda functions — return plain dicts without HTTP status codes wrapping.
## Scope
- Update error returns in `src/lambda/mcp_servers/test/lambda_function.py` to use `{"error": "..."}` format
- Remove `statusCode` and `body` wrapping from error responses
- Keep success response format as-is (already plain dict)
Contributor guide
Assessment
This issue has not been assessed yet.