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

Unable to parse data command output due to invalid json #485

Open
kyrofa opened this issue Jan 9, 2023 · 4 comments
Open

Unable to parse data command output due to invalid json #485

kyrofa opened this issue Jan 9, 2023 · 4 comments
Labels

Comments

@kyrofa
Copy link

kyrofa commented Jan 9, 2023

I was hoping to write a quick script to get some stats about our i18n keys, but there seems to be a bug in the --format option: I can't seem to get i18n-tasks to give me data I can process very easily. For example:

$ i18n-tasks data --format json
#StandWithUkraine
{"en":{"foo":"bar"},"es":{"baz":"qux"}}

It's not my intention to make a political statement, but this simply isn't valid json: jq barfs on it with "parse error: Invalid numeric literal at line 1, column 8". Both lines are printed to stdout, so it's not trivial to filter out non-json, requiring other workarounds. Any chance we could remove this when using the --format option?

@glebm
Copy link
Owner

glebm commented Jan 9, 2023

#StandWithUkraine is printed to stderr, while the json is printed to stdout.

This works just fine for me:

$ i18n-tasks data --format json | jq ".en.i18n_tasks.add_missing.added.one"

I think the parse error actually refers to a malformed jq query.

@glebm glebm added the question label Jan 9, 2023
@kyrofa
Copy link
Author

kyrofa commented Jan 9, 2023

Ah, right you are. I'm running this through docker, so they both end up on stdout for me.

@kyrofa
Copy link
Author

kyrofa commented Jan 9, 2023

Hmm... yeah this still requires workarounds for my use-case. Either I need to filter out stderr when running the command in the container (which isn't great, really-- I'd like to see errors), or I need to make sure all my tooling is set up on this particular container, which isn't something I was planning on doing. Any chance this is something you'd consider?

@glebm
Copy link
Owner

glebm commented Jan 10, 2023

This is a Docker bug, not an i18n-taska one, but good news is that it seems you can simply drop the -t flag from your docker run command.
moby/moby#725 (comment)

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

2 participants