Skip to content

Type hints are not validation #27

Description

@tobywf

Might be good to validate incoming payloads, so that they don't break the code in weird ways if they don't conform to what we expect.

Activity

  1. benbridts commented on Nov 21, 2019

    @benbridts
    Contributor

    Would running a static analyser during the submit process solve this?

  2. tobywf commented on Nov 21, 2019

    @tobywf
    ContributorAuthor

    I was thinking more along the lines of a ser/de and validation library like marshmallow or pydantic. Especially leaning towards the latter, since it works with data classes and type hints.

  3. benbridts commented on Nov 24, 2019

    @benbridts
    Contributor

    I just ran into this. A static analyser is indeed insufficient. We should probably also make the error make it clear that this is caused by an issue with the template

  4. tobywf commented on Nov 24, 2019

    @tobywf
    ContributorAuthor

    Yeah, it's rather annoying. The service can also do a bit more validation before calling the handler, too. But it would be good to have in any case, e.g. if a payload structure is changed in future. There's a few other things on my plate, but I've made progress using pydantic on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions