Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Yasha .json template error

See original GitHub issue

I have a valid .json file that works if I use it as is. This .json file has {{ .foo }} variables in it, which are internally processed ( these are not jinja variables) .

I am attempting to take this .json file and run it through the Yasha template command to create more .json files using jinja {{ bar }} to replace other hard coded variable values in the .json file.

If I run the .json file as is, it complains about the .json {{ .foo }} variables as expected. These variables can not be replaced or removed so I used the {% raw %} as described here to omit them.

My syntax looked like this: {% raw %} ...code line...{{ .foo } }...more code...{% endraw %}.

This should have allowed Yasha to ignore the .json variables with no complaints. Instead I receive the following error:

Traceback (most recent call last):
  File "/usr/local/bin/yasha", line 11, in <module>
    load_entry_point('yasha==3.1', 'console_scripts', 'yasha')()
  File "/usr/local/lib/python3.5/dist-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/yasha/scripts/", line 156, in cli
    vardict.update(parse_variables(variables, ex["variable_parsers"]))
  File "/usr/local/lib/python3.5/dist-packages/yasha/scripts/", line 35, in parse_variables
    return parser.parse(file)
  File "/usr/local/lib/python3.5/dist-packages/yasha/parsers/", line 35, in parse
    return json.loads('utf8'))
  File "/usr/lib/python3.5/json/", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

I think this is because a json validator is being run on the file first, before jinja is used. I didn’t expect any json validating.

If I change the file extension from .json to .txt it has no complaints and completes its jinja parsing correctly. I think because there is no json validating in this file extension.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

kblomqvistcommented, Oct 29, 2017

This should be fixed in 4.1. Thanks for reporting.

kblomqvistcommented, Oct 12, 2017

Yasha does not validate the template.

Read more comments on GitHub >

github_iconTop Results From Across the Web

kblomqvist/yasha: A command-line tool to render ... - GitHub
A command-line tool to render Jinja templates for great good - GitHub ... extremely picky on templates, e.g. undefined variables will raise an...
Read more >
JSON Template Errors - Deneb Showcase
The template has JSON errors “should NOT have additional property: vconcat” and “should not have additional property: mark & width” and ...
Read more >
Uploading with json causes missing template error
I think dropzone.js, is causing me a missing template error after I submit my form. In my coffeescript js file I have the...
Read more >
Solved: Invalid Template error with JSON analysis
Solved: Dear all, I am working on a PowerAutomate workflow linked to a Forms. When a user puts an attachment to the forms,...
Read more >
Resolve template validation or template format errors in ...
For "JSON not well-formed" or "YAML not well-formed" errors, see the Validate template syntax section. For "Unresolved resource dependencies ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found