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.

QUERY_STRING is assumed

See original GitHub issue

According to https://github.com/jonashaag/bjoern/issues/118, QUERY_STRING cannot be assumed as part of the incoming environment.

Request.args and Request.json_args should assume QUERY_STRING="" when it is not present in the environment.

https://github.com/nullism/pycnic/blob/1e60f41d01a4940c5ade0e9d7981d5fa71af67bd/pycnic/core.py#L77-L96

Example application:

from pycnic.core import WSGI, Handler

class Hello(Handler):
    def get(self):
        name = self.request.args.get("name", "Pycnic")
        return {"msg": "Hello, %s!" % (name)}

class app(WSGI):
    routes = [("/hello", Hello())]

if __name__ == "__main__":
    import bjoern
    bjoern.run(app, "127.0.0.1", 8000)

When run, requests to http://localhost:8000 err:

'QUERY_STRING'
Traceback (most recent call last):
  File "/XXXX/lib/python3.8/site-packages/pycnic/core.py", line 237, in __iter__
    resp = self.delegate()
  File "/XXXX/lib/python3.8/site-packages/pycnic/core.py", line 310, in delegate
    output = func(*args)
  File "app.py", line 6, in get
    name = self.request.args.get("name", "Pycnic")
  File "/XXXX/lib/python3.8/site-packages/pycnic/core.py", line 81, in args
    qs = self.environ["QUERY_STRING"]
KeyError: 'QUERY_STRING'

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aronatkinscommented, Apr 5, 2022

@nullism - It appears as if QUERY_STRING is not assumed to be present according to the linked PEP. I encountered an unset QUERY_STRING when playing with bjoern; not sure if other servers act similarly.

0reactions
nullismcommented, Apr 5, 2022

Uploaded as v0.1.9

Read more comments on GitHub >

github_iconTop Results From Across the Web

Query string | Node.js v19.3.0 Documentation
The node:querystring module provides utilities for parsing and formatting URL ... characters within the query string will be assumed to use UTF-8 encoding....
Read more >
Plus sign in query string - Stack Overflow
I placed a parameter value in the querystring with a plus(+) sign. But the plus sign disappear. How can I include the plus...
Read more >
Query String in Node.js and its Methods - KnowledgeHut
This method of changing an object to query string is called serialized. The latest UTF-8 encoding format is assumed unless we specify a ......
Read more >
How to get the query string values in JavaScript - Educative.io
A query string is used to assign a specific value to the parameter. For example: ... let's assume current URL is: https://example.com?name=Shubham&age=22
Read more >
Getting Query String Parameters Safely and Concisely in C# ...
But that assumes our parameter will actually be a numeric string. And you should never make assumptions about what's in your query string....
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