Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix json's anger at newlines #415
Conversation
|
Can we not fix the JSON? Reviewed 1 of 1 files at r1. Comments from Reviewable |
|
@metajack the newlines come in from pillar data which would get even less legible/editable if we removed them. So we could fix the json, but I'd prefer to keep the pillar pretty and just tell the parser not to break. |
|
@bors-servo r+ Ok. Definitely seem the right thing to do then. |
|
|
Fix json's anger at newlines
Error without this fix:
```
credentials = json.loads('{...}')
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
exceptions.ValueError: Invalid control character at: line 1 column 444 (char 443)
```
note: line 1 column 444 of the giant blob of secrets that I elided is the first occurrence of `\n` in the string.
Reason I think this works: Testing it in prod (sorry!) and also
http://stackoverflow.com/questions/9295439/python-json-loads-fails-with-valueerror-invalid-control-character-at-line-1-c
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/415)
<!-- Reviewable:end -->
|
|
Error without this fix:
credentials = json.loads('{...}')
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
exceptions.ValueError: Invalid control character at: line 1 column 444 (char 443)
Reason I think this works: Testing it and also
http://stackoverflow.com/questions/9295439/python-json-loads-fails-with-valueerror-invalid-control-character-at-line-1-c
d3b5ca0
to
a1ffb19
|
@bors-servo retry |
|
How urgent is this fix? I think there is a better way to do this (i.e. doesn't insert the newlines) but it will take me a while to investigate. |
|
The secrets causing the problem are |
|
@aneeshusa oh awesome! I'll take them out and close this. Thank you! |
edunham commentedJun 30, 2016
•
edited by larsbergstrom
Error without this fix:
note: line 1 column 444 of the giant blob of secrets that I elided is the first occurrence of
\nin the string.Reason I think this works: Testing it in prod (sorry!) and also
http://stackoverflow.com/questions/9295439/python-json-loads-fails-with-valueerror-invalid-control-character-at-line-1-c
This change is