8000 Documentation: explain why `BedrockResponse.is_json` always returns `True` regardless of Content-Type · Issue #7692 · aws-powertools/powertools-lambda-python · GitHub
[go: up one dir, main page]

Skip to content

Documentation: explain why BedrockResponse.is_json always returns True regardless of Content-Type #7692

@T90REAL

Description

@T90REAL

Expected Behaviour

resp_text.is_json() returns False because the content type is not JSON.

Current Behaviour

Both calls return True; is_json ignores content_type.

Code snippet

from aws_lambda_powertools.event_handler.api_gateway import BedrockResponse

resp_json = BedrockResponse(body={"ok": True}, content_type="application/json")
resp_text = BedrockResponse(body="plain", content_type="text/plain")

print(resp_json.is_json())
print(resp_text.is_json())
True
True

Possible Solution

Response.is_json() in the same file correctly looks at the Content-Type. BedrockResponse.is_json() should follow the same logic (checking for application/json or variants) instead of returning True unconditionally.

Steps to Reproduce

Run the repro script.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

Note: This issue was identified by an automated testing tool for academic research and manually verified. If you have any concerns about this type of reporting, please let me know, and I will adjust my workflow accordingly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0