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

PUT requests doesn't set default values for fields that have one defined #1280

sunbit opened this issue Jun 3, 2019 · 0 comments


Copy link

sunbit commented Jun 3, 2019

I've been upgrading an old Eve app to latest version, and we just find what we think is a bug introduced back at 2016 whith the 0.8 version. This is particulary bad for us as we're relyng on a field being set from a default value, as we're using that field for filtering the items of the resource.

Expected Behavior

After doing a PUT requests to replace an item, any field that has a default value should be set, as when doing an initial creation POST.

Minimal to reproduce the problem

MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'apitest'
IF_MATCH = False
    "test": {
        "schema": {
            "test_field": {"type": "string"},
            "default_field": {"type": "string", "default": "FOO", "allowed": ["FOO"]}
        "resource_methods": ["POST", "GET"],
        "item_methods": ["GET", "PUT"]

Minimal app to reproduce the problem

from eve import Eve
app = Eve()

if __name__ == '__main__':

Steps to reproduce it

curl -X POST -d '{"test_field": "value"}'  -H 'Content-Type: application/json' http://localhost:5000/test

curl -X GET http://localhost:5000/test/5cf55157f40227844c9b272c

  "_updated": "Mon, 03 Jun 2019 16:56:55 GMT",
  "default_field": "FOO",
  "test_field": "value",
  "_created": "Mon, 03 Jun 2019 16:56:55 GMT",
  "_id": "5cf55157f40227844c9b272c"

curl -X PUT -d '{"test_field": "value2"}'  -H 'Content-Type: application/json' http://localhost:5000/test/5cf55157f40227844c9b272c

Actual Behavior

The default value is not set and so effetively deleted from the document after the PUT:

curl -X GET http://localhost:5000/test/5cf55157f40227844c9b272c

  "_updated": "Mon, 03 Jun 2019 16:58:00 GMT",
  "_created": "Mon, 03 Jun 2019 16:56:55 GMT",
  "test_field": "value2",
  "_id": "5cf55157f40227844c9b272c",

I actually identified where it was introduced. The point were the old behaviour was removed from and the new one added in eve.validation:



The point here is if this is considered the wanted behaviour or something that has been broken. It would be useful to know @nicolaiarocci opinion about this, to be able to fix it properly. Looking at the code i see probably there are other features that are the cause of that changes that must be preserved.


  • Python version: 2.7.10
  • Eve version: 0.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants