GithubHelp home page GithubHelp logo

Comments (5)

zeratax avatar zeratax commented on June 10, 2024

yes that does sound sensible, thank you!

from matrix-registration.

jfmontanaro avatar jfmontanaro commented on June 10, 2024

Ok, unfortunately it looks like Flask returns a 400 error when force_json=True and the request body is empty. This can be overridden by extending the default flask.Request class object with a custom on_json_loading_failed() method that returns None in that particular case. Not sure if this is worth the added complexity, however.

As an alternative we could also specify silent=False, which would cause get_json() to return None any time JSON parsing fails. This seems like a really bad idea to me though because it would result in the server silently substituting default values any time the user supplies invalid JSON, which would be surprising at best and catastrophic at worst (e.g. someone tries to create a one-time use token with a short lifetime and ends up creating an unlimited-use token that lives forever.)

What do you think? Worth customizing the Request class or no?

from matrix-registration.

jfmontanaro avatar jfmontanaro commented on June 10, 2024

actually, wait - BadRequest is an exception, so we can just catch that and handle it. Let me just make sure that works.

Edit: Ok, looks like it does.

from matrix-registration.

seth586 avatar seth586 commented on June 10, 2024

Getting the same error when attempting to list tokens as documented, related?

curl -H "Authorization: SharedSecret verysecuresecret" \
     http://localhost:5000/token

from matrix-registration.

jfmontanaro avatar jfmontanaro commented on June 10, 2024

Looks like it could be related, does including a Content-Type: application/json header eliminate the issue?

from matrix-registration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.