-
Notifications
You must be signed in to change notification settings - Fork 184
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
AttributeError exception when accessing current user using Parse Server #155
Comments
I looked into this further and this appears to be a result of the /users/me endpoint in Parse Server adding additional attributes. The crash appeared to happen when parse-rest tried to set the className attribute. See parse-community/parse-server#3348 |
Hey @francisjervis - thanks for investigating. I doubt they will fix this upstream, since (1) this is not an official library, and (2) libraries shouldn't break when keys are appended (as opposed to missing). So I think the fault here is in this library. I will take a look at this in the next couple of days. In the meantime, please comment here and/or submit a PR if you are able to fix the issue. It should be pretty straight forward. Otherwise, a hacky would be to avoid the /users/me endpoint and just query the |
@milesrichardson Thanks for getting back to me; I agree, though given that parse-server is not supposed to break existing code, one could argue they should fix it too ;) I am going to hazard a guess at this being a failure in the convert_from_parse method in datatypes.py where the className key-value pair is outside the expected inputs. As noted in the parse-server issue, the new keys are "__type": "Object", I'm not 100% sure I understand how the lib handles converting responses to objects, so I can't offer much here - however I have tried retrieving users using a query, which does work as expected. Unfortunately I need to retrieve the current_user based on a session token passed from the browser cookie store, so I can't actually use that as a workaround (I think). If this is because the user object from a query doesn't have the extra keys, I'd be more inclined to see this as parse-server's issue (not that that necessarily means they will fix it, as you say). |
Yes, the issue is 99% chance in the Re: the workaround, you can query the |
With a quick glance, I think the issue is probably in this line: https://github.com/milesrichardson/ParsePy/blob/master/parse_rest/datatypes.py#L44 I will try to take a look at this later tonight. Let me know if you get a fix in the meantime. |
OK - my hacky conditional idea was to not try to convert className but I suspect that would break things? I've run a version with
and the crash is definitely happening after the iteration gets to key className. I'll give that a try, thanks for the suggestion! |
Or perhaps https://github.com/milesrichardson/ParsePy/blob/master/parse_rest/datatypes.py#L106 |
That code is only for deserializing nested pointer objects. But the section below it might be relevant. Have to head out now -- I'll take a look in a few hours. good luck |
Some more logs - thanks, I will keep hacking ;)
|
@francisjervis This should be fixed now. You can install from master like Since I included a link to this issue in a comment at the location of the fix in the code, I'm putting the solution in this comment. The problem was that @property
def className(self):
return self.__class__.__name__ The offending code: for key, value in six.iteritems(args):
setattr(self, key, ParseType.convert_from_parse(key, value)) As far as I can see there were two solutions:
for key, value in six.iteritems(args):
if key == 'className':
continue
setattr(self, key, ParseType.convert_from_parse(key, value))
for key, value in six.iteritems(args):
try:
setattr(self, key, ParseType.convert_from_parse(key, value))
except AttributeError:
continue I chose solution 2 because it's more "future proof" in the case that there are any other attributes that conflict with existing properties of the As an aside, the reason this happened only with |
Confirming this is working on my end, thanks for such a quick fix! |
EDIT FOR FUTURE: see #155 (comment) for solution
Using Parse Server, I am encountering a crash at line 442 in datatypes.py
setattr(self, key, ParseType.convert_from_parse(key, value))
when retrieving the currently logged in user. The user object appears to be being loaded correctly, looking at both the server logs and the error page from my (Django) app.
This only happens using the self-hosted server, not the Parse service.
The text was updated successfully, but these errors were encountered: