question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`rawQueryString` seems to be a string instead of bytes literals

See original GitHub issue

👋 @erm, first let me thank you for this ~great~ awesome library, as the author of another proxy for aws lambda I know this can be a 🕳️ sometimes.

I’m currently working on https://github.com/developmentseed/titiler which is a FastAPI based tile server. When deploying the lambda function using mangum and the new api gateway HTTP endpoint, most of my endpoints works except for the ones where I call request.url.scheme e.g: https://github.com/developmentseed/titiler/blob/master/titiler/api/api_v1/endpoints/metadata.py#L59

and I get AttributeError: 'str' object has no attribute 'decode'

Logs

File "/tmp/pip-unpacked-wheel-a0vaawkp/titiler/api/api_v1/endpoints/metadata.py", line 59, in tilejson
File "/tmp/pip-unpacked-wheel-xa0z_c8l/starlette/requests.py", line 56, in url
File "/tmp/pip-unpacked-wheel-xa0z_c8l/starlette/datastructures.py", line 45, in __init__
AttributeError: 'str' object has no attribute 'decode'

So looking at my cloudwatch logs I can deduce:

  1. in https://github.com/encode/starlette/blob/97257515f8806b8cc519d9850ecadd783b3008f9/starlette/datastructures.py#L45 starlette expect the query_string to be a byte literal

  2. in https://github.com/erm/mangum/blob/4fbf1b0d7622c19385a549eddfb603399a125bbb/mangum/adapter.py#L100-L106

it seems that Mangum is getting the rawQueryString for the event, and in my case I think this would be a string instead of a byte literal.

I’ll work on adding logging and test in my app to confirm this, but I wanted to share this to see if I was making sense 😉

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jordaneremieffcommented, May 9, 2020

Actually I ended up just pushing the 0.9.0 release (includes this change). Please follow-up if you run into any further issues.

0reactions
vincentsaragocommented, May 9, 2020

Everything works now 😄 🎉 thanks so much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3: How do I get a string literal representation of a byte ...
In Python 2 you have types str and unicode . str represents a simple byte string while unicode is a Unicode string.
Read more >
Python string literals in Markdown documents are treated as ...
When writing Python inside a Markdown document, string literals are mistakenly regarded as bytes, resulting in erroneous type warning.
Read more >
UTF-8 string literals - C# 11.0 draft specifications
This proposal adds the ability to write UTF8 string literals in C# and have them automatically encoded into their UTF-8 byte representation.
Read more >
Tokens - The Rust Reference
A non-raw byte string literal is a sequence of ASCII characters and escapes, preceded by the characters U+0062 ( b ) and U+0022...
Read more >
Strings, bytes, runes and characters in Go
At first, strings might seem too simple a topic for a blog post, ... Modify the examples above to use a slice of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found