playgameservices / management-tools

Tools for app developers to mange their Play Game services apps.
143 stars 73 forks source link

HttpError 400 "Invalid value for Long:" when updating leaderboards #23

Open daxliar opened 9 years ago

daxliar commented 9 years ago

After downloading all the leaderboards... python games-config.py leaderboard update If I try to update the same leaderboard with the same csv just generated I keep getting googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/games/v1configuration/leaderboards/xxxxxxxxxxxxxx?alt=json returned "Invalid value for Long:"> I've used the tool to download and update the achievements without any issue (using the same p12 and svcAccount arguments). I don't get if it's a bug or I'm doing something wrong.

gguuss commented 9 years ago

Can you try determining which line in the CSV is causing the failure and sharing the offending row?

harikishan7 commented 9 years ago

I get the same error reported by Daxliar. I am using the same p12 and svcAccount arguments. The script works fine with achievements. I inserted a print statement after line 855 in games-config.py. See below

obj_list = self._merge_items(items, 'id')
for i in obj_list:
  print i

I ran the tool along with logging_level DEBUG and here is my output. I removed my svcAccount and leaderboard id & any other authentication keys in the log for security reasons.

python games-config.py --logging_level DEBUG --p12 key.p12 --svcAccount xxxxxxxxxxxxxxxxx leaderboard insert xxxxxxxxxxxxx --incsv output.csv authentication done connect: (accounts.google.com, 443) send: 'POST /o/oauth2/token HTTP/1.1\r\nHost: accounts.google.com\r\nContent-Length: 590\r\ncontent-type: application/x-www-form-urlencoded\r\naccept-encoding: gzip, deflate\r\nuser-agent: Python-httplib2/0.9.1 (gzip)\r\n\r\ngranttype=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' reply: 'HTTP/1.1 200 OK\r\n' header: Content-Type: application/json; charset=utf-8 header: X-Content-Type-Options: nosniff header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate header: Pragma: no-cache header: Expires: Fri, 01 Jan 1990 00:00:00 GMT header: Date: Tue, 15 Sep 2015 23:25:19 GMT header: Content-Disposition: attachment; filename="json.txt"; filename=UTF-8''json.txt header: Content-Encoding: gzip header: P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." header: X-Frame-Options: SAMEORIGIN header: X-XSS-Protection: 1; mode=block header: Server: GSE header: Set-Cookie: NID=71=5xxxxxxxxxxxxxxxxxxxxxxxxxxx;Domain=.google.com;Path=/;Expires=Wed, 16-Mar-2016 23:25:19 GMT;HttpOnly header: Alternate-Protocol: 443:quic,p=1 header: Alt-Svc: quic=":443"; p="1"; ma=604800 header: Transfer-Encoding: chunked connect: (www.googleapis.com, 443) send: 'GET /discovery/v1/apis/gamesConfiguration/v1configuration/rest HTTP/1.1\r\nHost: www.googleapis.com\r\naccept-encoding: gzip, deflate\r\nauthorization: Bearer xxxxxxxxxxxxxxxx\r\nuser-agent: Python-httplib2/0.9.1 (gzip)\r\n\r\n' reply: 'HTTP/1.1 200 OK\r\n' header: Expires: Tue, 15 Sep 2015 23:30:19 GMT header: Date: Tue, 15 Sep 2015 23:25:19 GMT header: Cache-Control: public, max-age=300, must-revalidate, no-transform header: ETag: "ye6orv2F-1npMW3u9suM3a7C5Bo/6jg-uipHf0RCTmb-WNRfCarvz8o" header: Vary: Origin header: Vary: X-Origin header: Content-Type: application/json; charset=UTF-8 header: Content-Encoding: gzip header: X-Content-Type-Options: nosniff header: X-Frame-Options: SAMEORIGIN header: X-XSS-Protection: 1; mode=block header: Server: GSE header: Alternate-Protocol: 443:quic,p=1 header: Alt-Svc: quic=":443"; p="1"; ma=604800 header: Transfer-Encoding: chunked {u'scoreOrder': 'LARGER_IS_BETTER', u'scoreMin': '', u'token': '', u'scoreMax': '', u'draft': {u'scoreFormat': {u'currencyCode': '', u'suffix': {u'many': {u'translations': [{u'locale': '', u'value': ''}]}, u'two': {u'translations': [{u'locale': '', u'value': ''}]}, u'one': {u'translations': [{u'locale': '', u'value': ''}]}, u'few': {u'translations': [{u'locale': '', u'value': ''}]}, u'zero': {u'translations': [{u'locale': '', u'value': ''}]}, u'other': {u'translations': [{u'locale': '', u'value': ''}]}}, u'numberFormatType': 'NUMERIC', u'numDecimalPlaces': '0'}, u'iconUrl': '', u'name': {u'translations': [{u'locale': 'en-US', u'value': 'TopScore test'}]}, u'sortRank': '4'}, u'id': ''} send: 'POST /games/v1configuration/applications/xxxxxxxx/leaderboards?alt=json HTTP/1.1\r\nHost: www.googleapis.com\r\ncontent-length: 652\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: google-api-python-client/1.4.1 (gzip)\r\ncontent-type: application/json\r\nauthorization: Bearerxxxxxxxxxxxxxxxxxxxxx\r\n\r\n{"scoreOrder": "LARGER_IS_BETTER", "scoreMin": "", "token": "", "scoreMax": "", "draft": {"scoreFormat": {"currencyCode": "", "suffix": {"many": {"translations": [{"locale": "", "value": ""}]}, "two": {"translations": [{"locale": "", "value": ""}]}, "one": {"translations": [{"locale": "", "value": ""}]}, "few": {"translations": [{"locale": "", "value": ""}]}, "zero": {"translations": [{"locale": "", "value": ""}]}, "other": {"translations": [{"locale": "", "value": ""}]}}, "numberFormatType": "NUMERIC", "numDecimalPlaces": "0"}, "iconUrl": "", "name": {"translations": [{"locale": "en-US", "value": "TopScore test"}]}, "sortRank": "4"}, "id": ""}' reply: 'HTTP/1.1 400 Bad Request\r\n' header: Vary: Origin header: Vary: X-Origin header: Content-Type: application/json; charset=UTF-8 header: Content-Encoding: gzip header: Date: Tue, 15 Sep 2015 23:25:19 GMT header: Expires: Tue, 15 Sep 2015 23:25:19 GMT header: Cache-Control: private, max-age=0 header: X-Content-Type-Options: nosniff header: X-Frame-Options: SAMEORIGIN header: X-XSS-Protection: 1; mode=block header: Server: GSE header: Alternate-Protocol: 443:quic,p=1 header: Alt-Svc: quic=":443"; p="1"; ma=604800 header: Transfer-Encoding: chunked Traceback (most recent call last): File "games-config.py", line 810, in main(sys.argv) File "games-config.py", line 171, in main api.insert(flags) File "games-config.py", line 801, in insert rsp = self.api.insert(applicationId=flags.appId, body=i).execute() File "/Library/Python/2.7/site-packages/oauth2client/util.py", line 142, in positional_wrapper return wrapped(_args, **kwargs) File "/Library/Python/2.7/site-packages/googleapiclient/http.py", line 729, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/games/v1configuration/applications/708694881652/leaderboards?alt=json returned "Invalid value for Long:">

harikishan7 commented 9 years ago

Hello - its been a while since I posted this log. Any update on this would be greatly appreciated.

dbertoletti commented 5 years ago

Any update on this? Is really frustrating when you have to update manually a lot of leaderboards having many translations...

gguuss commented 5 years ago

Oof, I am no longer working on this but can try and find out.

gguuss commented 5 years ago

As far as I can tell, the error is occurring because the id is invalid:

{"scoreOrder":"LARGER_IS_BETTER", "scoreMin": "", "token": "", "scoreMax": "", "draft": {"scoreFormat": {"currencyCode": "", "suffix": {"many": {"translations": [{"locale": "", "value": ""}]}, "two": {"translations": [{"locale": "", "value": ""}]}, "one": {"translations": [{"locale": "", "value": ""}]}, "few": {"translations": [{"locale": "", "value": ""}]}, "zero": {"translations": [{"locale": "", "value": ""}]}, "other": {"translations": [{"locale": "", "value": ""}]}}, "numberFormatType": "NUMERIC", "numDecimalPlaces": "0"}, "iconUrl": "", "name": {"translations": [{"locale": "en-US", "value": "TopScore test"}]}, "sortRank": "4"}, "id": ""}'

See "id": "" - that is probably where the proto is not properly compiling. If you drop entries where the id is missing or determine why the id is missing, you can probably prevent this issue.

/FYI @claywilkinson, who I believe originally authored the tool.

dbertoletti commented 5 years ago

Thank you very much @gguuss I've tried in different ways, dropping the entire id column from the csv file or by setting a long value to it or leaving the cell empty but I always get into a problem. In one case it expects the id value as it's mandatory and in all the other cases it keep complaining it ins't a valid value for Long.