aws-samples / aws-samples/amazon-bedrock-samples

KeyError: 'requestBody' : File "/var/task/lambda_function.py", line 15, in get_named_property event['requestBody']['content']['application/json']['properties']

Open
#226 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
1.5k
Forks
734
Avg merge
1d 6h
Merged PRs (30d)
4

Description

Hi,

I'm testing "create an action group" for a bedrock agent that can call a lambda function. Creating this action group calls for having an OpenAPI schema which defines the function endpoints, required arguments, and the returns.

However, I'm seeing the following error

```
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html

[ERROR] KeyError: 'requestBody'
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 97, in lambda_handler
internal_id = get_named_property(event, "internalId")
File "/var/task/lambda_function.py", line 15, in get_named_property
event['requestBody']['content']['application/json']['properties']
```

Can someone please look into this?

Contributor guide

Open the contributing guide

Research direction

Start with lambda_function.py, especially get_named_property and lambda_handler, and compare the Bedrock action group's event shape with the code's requestBody access. Reproduce the action-group invocation using the OpenAPI schema described in the issue; done means the handler no longer raises the reported KeyError for that event.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, openapi, python
Domain
api, backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.