Comments (15)
@DariusKunce Confirmed! We'll add this into the next sprint to fix
def test_weird_issue():
# GIVEN a Http API V2 proxy type event
app = APIGatewayRestResolver(enable_validation=True)
class FunkyTown(BaseModel):
parameter: str
@app.get("/my/path")
def my_path(
parameter: Annotated[str | None, Query(alias="parameter1")] = None,
) -> Response[FunkyTown]:
assert isinstance(app.current_event, APIGatewayProxyEvent)
assert parameter == "value"
return Response(200, content_types.APPLICATION_JSON, FunkyTown(parameter=parameter))
result = app(load_event("apiGatewayProxyEvent.json"), {})
print(result)
assert result["statusCode"] == 200
from powertools-lambda-python.
The issue isn't related to the alias but the fact that the openapi_validation.py
handles all query strings with _normalize_multi_query_string_with_param
and takes the first value of the item.
With "queryStringParameters": { "productType": "Category1" }
it's normalize to: "productType": "C"
With "multiValueQueryStringParameters": { "productType": ["Category1"] }
it's normalize correctly to: "productType": "Category1"
I was able to find this as I was trying to validate the min length of a query string parameter (def get_hello(fname: Annotated[Optional[str], Query(min_length=4)] = None) -> HelloWorld:
and fname
was always too short... as it was always truncated to 1 character.
The line truncating the value is here
from powertools-lambda-python.
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
from powertools-lambda-python.
Hi @DariusKunce this is on my list for verification tomorrow, thanks for submitting it!
from powertools-lambda-python.
@DariusKunce we're aiming to make a release tomorrow with this fix ahead of schedule -- let us know if you're blocked by this and we can make it today.
from powertools-lambda-python.
Thanks a lot for the timely comment @jpoissant.
@rubenfonseca i think we had mixed messaging and this wasn't fixed -- if you can't look into it tomorrow morning before release, let me know pretty plz
from powertools-lambda-python.
Thank you so much @jpoissant I'm looking at this right now
from powertools-lambda-python.
The issue isn't related to the alias but the fact that the
openapi_validation.py
handles all query strings with_normalize_multi_query_string_with_param
and takes the first value of the item.With
"queryStringParameters": { "productType": "Category1" }
it's normalize to:"productType": "C"
With
"multiValueQueryStringParameters": { "productType": ["Category1"] }
it's normalize correctly to:"productType": "Category1"
@jpoissant I need to understand the problem a little bit better, since I'm unable to reproduce the problem. Can you please confirm which event handler are you using? Is it the APIGatewayRestResolver ?
Reason I'm asking is that the REST API Gateway will always send multiValueQueryStringParameters
, so the existing code already works correctly.
So I need to understand what scenario do you have where you only have queryStringParameters
. Can you please clarify?
from powertools-lambda-python.
@rubenfonseca I am using the APIGatewayHttpResolver
resolver. I just tried with the APIGatewayRestResolver
and it work. So the bug is only related to the API Gateway v2 proxy payload format
from powertools-lambda-python.
@rubenfonseca would it be better to open a new bug for the APIGatewayHttpResolver
resolver?
from powertools-lambda-python.
Related Issues (20)
- Feature request: On batch processing, fill in processor result even if BatchProcessingError is raised HOT 5
- Maintenance: Enable Redis e2e tests HOT 3
- Allow logging additional keys as a context manager HOT 8
- Nathan Hanks: Boost App Engagement with AWS CloudWatch Metrics & Powertools for AWS HOT 3
- Maintenance: revert AWS CDK as a development dependency HOT 1
- Bug: OpenAPI schema invalid when using Pydantic v2 (latest) HOT 10
- Bedrock Agent resolver security assessment HOT 4
- Bedrock Agents resolver blog post HOT 1
- Static typing: headers in Response should be Mapping instead of Dict HOT 3
- Maintenance: Refactor artifact name strategy for parallel uploads HOT 5
- Maintenance: Roadmap update HOT 3
- Bug: Logs populating into cloudwatch as multiple lines instead of a single object HOT 10
- Maintenance: Update readme to style badge and remove email HOT 3
- Maintenance: Layer ARN release update is partially working HOT 4
- Bug: payload validation is skipped when item is returned via `ReturnValuesOnConditionCheckFailure` HOT 11
- Docs: remove leftover announcement banner HOT 2
- [I Made This]: reinvent session & code with Heitor HOT 3
- Docs: Fix feature flags documentation HOT 4
- Bug: Swagger generated UI has JSON format invalid URL HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powertools-lambda-python.