Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different unknown arguments behaviour locally vs on production #611

Open
koko236 opened this issue Feb 22, 2024 · 2 comments
Open

Different unknown arguments behaviour locally vs on production #611

koko236 opened this issue Feb 22, 2024 · 2 comments
Labels

Comments

@koko236
Copy link

koko236 commented Feb 22, 2024

This is a bit of a sanity check question and I'm not sure which library I should post it in, sorry about that.

TLDR: Q: Is there a flag which disables check for extra params in request locally / in debug / dev scenario? I seem to experience such a thing.

I have Flask app (Flask==2.3.3) with: flask-smorest==0.42.3, marshmallow==3.20.1, webargs==8.4.0.

I have Marshmallow schema defined with a few fields and a Smorest blueprint endpoint with arguments decorator which expects a SUBSET of the schema (no id, date_created, etc.):

    @blp.arguments(ItemSchema(only=("name", "description", "language")))
    @blp.response(201, ItemSchema)
    @auth_token_required()
    def put(self, data, project_uuid, site_uuid):

What happens is when I run this locally (in Docker but in dev mode) I can run PUT request with extra params and it goes through, but when I run the same code on remote server with production settings I get '"Unknown field" errors for the extra fields.

What's more I added unknown=ma.EXCLUDE:

@blp.arguments(ItemSchema(only=("name", "description", "language"), unknown=ma.EXCLUDE))

which solves the problem on the remote server. But even if I tried to set it explicitly to RAISE it is still ignored locally - I can pass extra arguments without errors. These settings seem to be completely ignored. Is there any obvious thing that may affect it?

@lafrech
Copy link
Member

lafrech commented Feb 22, 2024 via email

@koko236
Copy link
Author

koko236 commented Feb 22, 2024

Thanks for suggestion @lafrech. They are installed during Docker Compose build from requirements.txt file which is the same for both envs. I rebuild the containers all the time and if requirements.txt changes it triggers pip install so I don't see how they could differ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants