eve-mongoengine icon indicating copy to clipboard operation
eve-mongoengine copied to clipboard

KeyError _etag

Open paulocheque opened this issue 9 years ago • 3 comments

I am getting this exception with a simple code. It breaks the /person endpoint and all of other endpoints I receive a 404 error.

screen shot 2015-09-14 at 5 22 28 pm

Using:

  • eve 0.5.3 or in-dev

  • eve-Mongoengine 0.0.9

    class Person(mongoengine.Document): name = mongoengine.StringField() age = mongoengine.IntField()

    app = Eve() ext = EveMongoengine(app) ext.add_model(Person)

paulocheque avatar Sep 15 '15 04:09 paulocheque

I had this issue until I changed some settings with the projection, at which point _etag existed. Collections without projection changes had this error, and those with projection changes didn't. Not sure what the underlying issue is but this fixes it.

from models import Person, Address
from eve_mongoengine import EveMongoengine
ext = EveMongoengine(app)
# Register model
ext.add_model([Person, Address])
# Remove password hash and salt from projections, this collection was error free
app.config['SOURCES']['person']['projection'] = {'salt': 0, 'password': 0}
# This next line removed the error, but you need to set all the fields
app.config['SOURCES']['address']['projection'] = {'street': 1, 'zipcode': 1, 'city': 1, 'state': 1}
  • Eve 0.6.4
  • MongoEngine 0.10.6
  • Eve-Mongoengine 0.0.9

bbbbbailey avatar Jul 10 '16 17:07 bbbbbailey

See also Eve issue #569.

Qualifying the offending code to read:

projection = [rev_map[field] for field in projection if field in rev_map]

gets past the problem, since the _etag is auto-generated if missing.

FredLoney avatar Jul 15 '16 18:07 FredLoney

@seglberg any update on this?

lig avatar Oct 17 '17 09:10 lig