Before, the jinja template was constructing the output JSON
manually injecting values from the config object as simple
values.
This worked well as long as the values did not contain
any special characters like newlines.
Hence, it causes invalid JSON to be rendered in case of
multiline strings as values, e.g. passed as argument for
site_description which was the use case at the bug report
at backstage/backstage issue #10277.
Other special characters like double-quotes could have caused
a similar effect.
This change introduces a test to reproduce the case
and provides a new jinja template which makes use of
the tojson filter introduced in jinja 2 to generate
valid JSON.
As previously, the values have been expected to be of type
string, the string filter is used for values on top to
guarantee this. (E.g., a numeric value passed as value
would still result in a string value at the rendered JSON.)
Before, the jinja template was constructing the output JSON manually injecting values from the
config
object as simple values.This worked well as long as the values did not contain any special characters like newlines. Hence, it causes invalid JSON to be rendered in case of multiline strings as values, e.g. passed as argument for
site_description
which was the use case at the bug report at backstage/backstage issue #10277. Other special characters like double-quotes could have caused a similar effect.This change introduces a test to reproduce the case and provides a new jinja template which makes use of the
tojson
filter introduced in jinja 2 to generate valid JSON.As previously, the values have been expected to be of type string, the
string
filter is used for values on top to guarantee this. (E.g., a numeric value passed as value would still result in a string value at the rendered JSON.)Closes: #57 Relates-to: backstage/backstage issue #10277 Signed-off-by: Patrick Jungermann Patrick.Jungermann@gmail.com