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

Add entity oid to traceback #628

Closed
osimicek opened this issue Apr 15, 2014 · 7 comments
Closed

Add entity oid to traceback #628

osimicek opened this issue Apr 15, 2014 · 7 comments
Labels
Milestone

Comments

@osimicek
Copy link

Hi,
I use mongoengine and rockmongo to manage my MongoDB. Sometimes in rockmongo I make a mistake and fill attribute with empty string "" instead of oid.
Then I get this error:

File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 81, in _iter_results
self._populate_cache()
File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/mongoengine/queryset/queryset.py", line 93, in _populate_cache
self._result_cache.append(self.next())
File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 1141, in next
_auto_dereference=self._auto_dereference)
File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/mongoengine/base/document.py", line 570, in _from_son
else field.to_python(value))
File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/mongoengine/base/fields.py", line 392, in to_python
value = ObjectId(value)
File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/bson/objectid.py", line 92, in __init__
self.__validate(oid)
File "/home/vagrant/.virtualenvs/shop-demo/lib/python2.7/site-packages/bson/objectid.py", line 196, in __validate
raise InvalidId("%s is not a valid ObjectId" % oid)

The traceback is useful but I´m not able to track down which entity causes this. Is there any chance to add to traceback an information about entity that is processed (oid or dict repr.)?

Thanks for answer.

@lig
Copy link
Contributor

lig commented Apr 15, 2014

@osimicek it will be usefull to look at the printed line as raise InvalidId("%s is not a valid ObjectId" % oid) does exactly what you want. It prints out the line "%s is not a valid ObjectId" where %s is oid value. That is empty string in your case.

It looks like this issue is related to #618 as both rely on ObjectId validation.

@lig lig added the bug label Apr 15, 2014
@lig lig added this to the 0.8.x milestone Apr 15, 2014
@osimicek
Copy link
Author

I don´t need to see the wrong oid attribute. I need to find whole wrong entity.
Example:

{
   "_id":  ObjectId("5305f722ee6da1059fab208d"),
   "parentId": ""
}

I need to know oid of entity which is wrong. In this case 5305f722ee6da1059fab208d.
The oid is not the only type that can cause error. For example dateTime can by wrong too.

@lig
Copy link
Contributor

lig commented Apr 15, 2014

It is not a good idea to report whole entity by default as it could contain
sensitive data.

May be its time to think about logging exceptions and different reports on
different logging levels.

On Tue, Apr 15, 2014 at 1:44 PM, osimicek [email protected] wrote:

I don´t need to see the wrong oid attribute. I need to find whole wrong
entity.
Example:

{
"_id": ObjectId("5305f722ee6da1059fab208d"),
"parentId": ""
}

I need to know oid of entity which is wrong. In this case
5305f722ee6da1059fab208d.
The oid is not the only type that can cause error. For example dateTime
can by wrong too.


Reply to this email directly or view it on GitHubhttps://github.com//issues/628#issuecomment-40463260
.

Serge Matveenko
mailto: [email protected]
github: http://lnkfy.com/1
linkedin: http://lnkfy.com/S

Пародуй.рф — http://www.parodui.ru/
Специализированный магазин электронных сигарет
СПб, Ленинский проспект 79 корп. 3, +7 (812) 951-25-24

@osimicek
Copy link
Author

Whole traceback contains sensitive data. Tracebacks must not be visible on production servers!
I hoped, a traceback could contain information about entity and its attribute.
e.g.

InvalidId("%s is not a valid ObjectId" % oid) in parentId attribute
of entity with oid 5305f722ee6da1059fab208d 

@lig
Copy link
Contributor

lig commented Apr 15, 2014

pk is not neccessary ObjectId instance. It could be user email e.g.
that not meant to be in the logs.

Thus you have the right point on more informative exceptions and we must to
remember about log level and disclosing sensitive data.

On Tue, Apr 15, 2014 at 2:50 PM, osimicek [email protected] wrote:

Whole traceback contains sensitive data. Tracebacks must not be visible on
production servers!
I hoped, a traceback could contain information about entity and its
attribute.
e.g.

InvalidId("%s is not a valid ObjectId" % oid) in parentId attribute
of entity with oid 5305f722ee6da1059fab208d

Reply to this email directly or view it on GitHubhttps://github.com//issues/628#issuecomment-40468480
.

Serge Matveenko
mailto: [email protected]
github: http://lnkfy.com/1
linkedin: http://lnkfy.com/S

ðÁÒÏÄÕÊ.ÒÆ -- http://www.parodui.ru/
óÐÅÃÉÁÌÉÚÉÒÏ×ÁÎÎÙÊ ÍÁÇÁÚÉÎ ÜÌÅËÔÒÏÎÎÙÈ ÓÉÇÁÒÅÔ
óðÂ, ìÅÎÉÎÓËÉÊ ÐÒÏÓÐÅËÔ 79 ËÏÒÐ. 3, +7 (812) 951-25-24

@lig
Copy link
Contributor

lig commented Nov 25, 2014

This looks like feature request. Not a bug.

@DavidBord
Copy link
Contributor

This is how an empty string as id will appear in the exception message:

InvalidId:  is not a valid ObjectId

And that's the way to identify a document uniquely
It is a bit difficult to notice but the multiple spaces between InvalidId: to is should have implied that you should look for a document with an empty string id

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

3 participants