Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lambda-petclinic/sample-apps/function2/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def lambda_handler(event, context):
pet_id = query_params.get('petid')

try:
response = table.scan()
# Optimize scan operation with pagination limit to reduce latency
response = table.scan(Limit=100)
items = response.get('Items', [])

print("Record IDs in DynamoDB Table:")
Expand All @@ -40,4 +41,4 @@ def lambda_handler(event, context):
return {
'statusCode': 500,
'body': json.dumps({'error': str(e)})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ def lambda_handler(event, context):
owners = query_params.get('owners')
pet_id = query_params.get('petid')


if pet_id == "111111111111":
raise Exception('Fail to parse the request. Cause: NullPointerException')

# Improved input validation with proper error responses
if owners is None or pet_id is None:
raise Exception('Missing owner or pet_idßßßß')
return {
'statusCode': 400,
'body': json.dumps({'error': 'Missing required parameters: owners or petid'}),
'headers': {
'Content-Type': 'application/json'
}
}

if record_id is None:
return {
Expand Down