google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
6.92k stars 437 forks source link

std.rstripChars functionality broken in v0.19.1 #1034

Closed niels-s closed 6 months ago

niels-s commented 1 year ago

We tried to upgrade from 0.18.0 to 0.19.1, but we stumbled on a regression, it seems, in the std.rstripChars function.

When we try to remove a newline from our templated string

{
test: std.rstripChars(|||
               Made with ❤️ and [Grafonnet](https://github.com/grafana/grafonnet-lib). [Contribute to this dashboard on GitHub.com](https://github.com/onesignal/infra/blob/main/dashboards/%(filePath)s)
            ||| % { filePath: 'billing/main.dashboard.jsonnet' }, '\n')
}

The result in version 0.18.0 is correct:

{
   "test": "Made with ❤️ and [Grafonnet](https://github.com/grafana/grafonnet-lib). [Contribute to this dashboard on GitHub.com](https://github.com/onesignal/infra/blob/main/dashboards/billing/main.dashboard.jsonnet)"
}

However, after upgrading to version 0.19.1, this is the result:

{
   "test": "Made with ❤️ and [Grafonnet](https://github.com/grafana/grafonnet-lib). [Contribute to this dashboard on GitHub.com](https://github.com/onesignal/infra/blob/main/dashboards/billing/main.dashboard.json"
}

Another conclusion is the first link we add also seems to influence the result. If we compile

{
test: std.rstripChars(|||
              [Contribute to this dashboard on GitHub.com](https://github.com/onesignal/infra/blob/main/dashboards/%(filePath)s)
            ||| % { filePath: 'billing/main.dashboard.jsonnet' }, '\n')
}

It works and yields the same results in v0.18.0 and v0.19.1

{
   "test": "[Contribute to this dashboard on GitHub.com](https://github.com/onesignal/infra/blob/main/dashboards/billing/main.dashboard.jsonnet)"
}
sbarzowski commented 1 year ago

We'll need to investigate. Thanks for reporting.

netomi commented 1 year ago

Tested that with different versions of jsonnet (0.18.0, 0.19.0, 0.19.1, latest version a3a1f0914dc3d2a6fd851edc8e5dc1ef52e372f7) and they all produce in the same correct result.

Tested on ubuntu 22.04.

johnbartholomew commented 6 months ago

I haven't been able to reproduce this, and a previous commenter wasn't able to reproduce either. I'll close this as wontfix/not reproducible, but if you're still aware of it happening and can reproduce then please reopen it!