Field does not exist on the Document

20 views
Skip to first unread message

Gabriel Blondeau

unread,
Sep 30, 2020, 4:25:59 AM9/30/20
to MongoEngine Users

Hello :)

I'm strangling with the weird error. mongoEngine is raising: The fields "field" does not exist on the document "Model" even if the field is in my object/document

I spent my entire last week to solve that issue...

I tried to add in the metadata: Strict == False

I didn't manage to reproduce it locally, it happens only in my QA environment.

------------------------------------

MongoEngine version: 0.18.2

Error from Sentry:
> The fields "{'xml_digest'}" do not exist on the document "Store"

Object values:
{
    _cls:"Store",
    created:"2016-06-11T18:09:19.068000+00:00",
    xml_digest:{
        md5:"=====",
        sha1:"=====",
        sha256:"=====",
        sha512:"====="
    }
}

A piece of my Store model and his XMLDigest EmbeddedDocument:
class XMLDigest(EmbeddedDocument):
    sha1 = StringField()
    sha256 = StringField()
    sha512 = StringField()
    md5 = StringField()

    def set_digest(self, content):
        self.sha1 = hashlib.sha1(content).hexdigest()
        self.sha256 = hashlib.sha256(content).hexdigest()
        self.sha512 = hashlib.sha512(content).hexdigest()
        self.md5 = hashlib.md5(content).hexdigest()
        return self


class Store(Document):
    created = ArrowDateTimeField(required=True, default=lambda: now())
    
    xml_digest = EmbeddedDocumentField(XMLDigest, required=False)

    meta = {
        'collection': 'stores',
        'allow_inheritance': True,
        'strict': False
    }
Reply all
Reply to author
Forward
0 new messages