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

dogma returns error invalid json when called dogma cat --jsonpath #36

Closed
wingyplus opened this issue Aug 14, 2019 · 8 comments · Fixed by #37
Closed

dogma returns error invalid json when called dogma cat --jsonpath #36

wingyplus opened this issue Aug 14, 2019 · 8 comments · Fixed by #37

Comments

@wingyplus
Copy link

wingyplus commented Aug 14, 2019

These steps below I copied from tutorial.

Reproduce steps:

start centraldogma with docker command:

$ docker run -p 36462:36462 --name dogma --rm line/centraldogma

Then running with following steps:

$ cat test.sh
#!/bin/sh

conn='http://localhost:36462'

./dogma -c $conn new projFoo
./dogma -c $conn new projFoo/repoA
echo '{"a":"b"}' > a.json
./dogma -c $conn put projFoo/repoA/samples/a.json a.json -m 'Add a.json'
./dogma -c $conn ls
./dogma -c $conn cat projFoo/repoA/samples/a.json
./dogma -c $conn cat --jsonpath '$.a' projFoo/repoA/samples/a.json

Expected result:

The ./dogma -c http://localhost:36462 cat --jsonpath '$.a' in the last step should returns "b" as mentioned in tutorial website.

Actual Result

invalid character 'b' looking for beginning of value

Dogma version:

$ ./dogma
Central Dogma version 0.41.1 (241c5a8)

And found it in current master branch.

@minwoox
Copy link
Member

minwoox commented Aug 14, 2019

Thanks for the report. Let me take a look it soon.

@wingyplus
Copy link
Author

wingyplus commented Aug 15, 2019

I capturing response body that come from centraldogma service (run via docker):

{"revision":2,"path":"/samples/a.json","type":"JSON","content":"b","url":"/api/v1/projects/projFoo/repos/repoA/contents/samples/a.json"}

The content return "b". If we want to return "b" as tutorial mentioned, content must be "\"b\"".

Is it bug on centraldogma service?

@wingyplus
Copy link
Author

wingyplus commented Aug 15, 2019

@wingyplus
Copy link
Author

@minwoox Is it possible that UnmarshalJSON strip " out of content by using json.Unmarshal?

ref: https://github.com/line/centraldogma-go/blob/master/content_service.go#L88

@minwoox
Copy link
Member

minwoox commented Aug 21, 2019

@wingyplus Sorry about the late response. Was on a business trip and couldn't take care of this issue.
Let me just reproduce it. Thanks!
BTW, are you using Central Dogma?

@wingyplus
Copy link
Author

wingyplus commented Aug 21, 2019

@minwoox Sorry for disturbing you. I see it using inside LINE Man Team (but another team not my team). And I interesting to use it in my personal project. :)

@minwoox
Copy link
Member

minwoox commented Aug 21, 2019

@wingyplus Ah that's cool! If you want to talk directly, you can use the company slack #help_centraldogma. :-)

@wingyplus
Copy link
Author

@minwoox Thanks for your guide. :D

minwoox added a commit to minwoox/centraldogma-go that referenced this issue Aug 29, 2019
Motivation:
Currently, we indent JSON content if the `EntryType` is `JSON`.
However, the content can be just a string when we use JSON path.

Modification:
- Do not indent when the content is not JSON object

Result:
- Fix line#36
- You no longer see parsing error when fetching JSON content using JSON path
trustin pushed a commit that referenced this issue Sep 3, 2019
Motivation:
Currently, we indent JSON content if the `EntryType` is `JSON`.
However, the content can be just a string when we use JSON path.

Modification:
- Do not indent when the content is not JSON object

Result:
- Fix #36
- You no longer see parsing error when fetching JSON content using JSON path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants