618 Commits

Author SHA1 Message Date
John Bartholomew
567b61ac4a release: v0.22.0 v0.22.0 2026-03-24 15:55:53 +00:00
Florian Pradines
456331f665 refactor: use MaxStack as depth limit instead of fixed constant 2026-03-23 20:36:15 +00:00
Florian
502106b2a2 fix: add missing linter golden files for cyclic tests 2026-03-23 20:36:15 +00:00
Florian
033195b173 fix: add stack frame accounting to manifest builtins
builtinManifestJSONEx, builtinManifestYamlDoc and builtinManifestTomlEx
use native Go recursion that bypasses MaxStack. A self-referential
object like {a: $} causes unbounded memory allocation until OOM.

Add i.newCall() at the top of each recursive closure, matching the
pattern used by manifestJSON in interpreter.go.
2026-03-23 20:36:15 +00:00
Simon Gerber
86c6dc133a
Extend "Build and Publish Python Package" workflow to build Linux aarch64 wheels
Build Linux aarch64 wheels by extending the build_wheels job in the
workflow to also run on an `ubuntu-22.04-arm` runner.

In order for this to work, the commit also extends the `install-go.sh`
helper architecture aware.
2026-03-19 10:30:49 +01:00
John Bartholomew
b5ef4cd9c4 release: prepare to release v0.22.0-rc1 v0.22.0-rc1 2026-03-12 12:26:51 +00:00
John Bartholomew
160987fd26 deps: update referenced github actions to latest
For GitHub first party actions (actions from the github.com/actions
organisation) we just use a major version tag. For actions from any
other source we pin to an exact commit SHA1 (and put the version in
a comment)
2026-03-12 12:26:51 +00:00
John Bartholomew
7b3fbdd0a4 update cpp-jsonnet to (unreleased) 3a7b2a565827635615f8a9432d94941e2a827c70 2026-03-08 20:16:33 +00:00
John Bartholomew
154626d157 print names of reformatted files when using jsonnetfmt --test or --in-place
Fixes #768

Also the go-jsonnet version of https://github.com/google/jsonnet/issues/365
2026-03-08 20:16:33 +00:00
John Bartholomew
509404f29c update cpp-jsonnet to (unreleased) 833f18402b6b6a2da0b2fae75446a1e14b9116dd 2026-03-08 13:43:15 +00:00
John Bartholomew
4e0952795e improve handling of YAML document streams in std.parseYaml
This doesn't make them fully correct, in particular directives sections
(e.g., "%YAML 1.2" directive before a document start marker) are not
handled correctly, but they weren't handled correctly before, either.

It also doesn't recognise or try to do anything about document end
markers (`...`).

This fix does allow scalar documents to be on the same line as the
document start tag which is valid per examples in the YAML spec,
see for example https://yaml.org/spec/1.2.1/#id2760844
(YAML 1.2.1 spec, section 2.3 Scalars)

It also matches the C++ jsonnet output for std.parseYaml("42\n---"),
which is a stream of two documents, a scalar and then an empty document
(where the empty document is interpreted as JSON null)
2026-03-08 13:43:04 +00:00
John Bartholomew
80e9deb4d8 restrict bitwise operations argument range to the safe-integer range
Fixes #858.

This is intended to match the restriction added in C++ Jsonnet in
https://github.com/google/jsonnet/pull/1217
and updated in https://github.com/google/jsonnet/pull/1240
2026-03-05 13:39:10 +00:00
He-Pin
2b6894d81e chore: update stdlib_smoke_test.jsonnet with with float closing test 2026-03-01 00:01:17 +08:00
John Bartholomew
5400c708a2 add test cases for add_plus_object formatter pass 2026-02-24 18:28:34 +00:00
John Bartholomew
1ef3750d6c simplify and clean up formatter_test
There were various bits of dead code and easily simplified things.
2026-02-24 18:28:21 +00:00
John Bartholomew
209e9f0d5c add parens where necessary when converting implicit-plus to explicit-plus 2026-02-24 18:28:12 +00:00
John Bartholomew
22fb64fe50 extract precedence info from internal/parser to a new internal/ast package 2026-02-24 18:01:14 +00:00
John Bartholomew
7792b06ec6 update cpp-jsonnet to (unreleased) e4981ff1199f24fc6d3110311196aebfeca76eca
Also fix update_cpp_jsonnet.sh because the bazel/ directory was removed.

Update test goldens (due to line shifts caused by standard library changes)
2026-02-19 21:42:13 +00:00
dependabot[bot]
e56516d18e
chore(deps): bump the go_modules group across 2 directories with 1 update
Bumps the go_modules group with 1 update in the / directory: [golang.org/x/crypto](https://github.com/golang/crypto).
Bumps the go_modules group with 1 update in the /examples/bazel directory: [golang.org/x/crypto](https://github.com/golang/crypto).


Updates `golang.org/x/crypto` from 0.36.0 to 0.45.0
- [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.45.0)

Updates `golang.org/x/crypto` from 0.36.0 to 0.45.0
- [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.45.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.45.0
  dependency-type: direct:production
  dependency-group: go_modules
- dependency-name: golang.org/x/crypto
  dependency-version: 0.45.0
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-19 10:22:12 +00:00
John Bartholomew
acd4ea256d restrict file writes for --multi to the specified output directory 2026-02-18 23:06:15 +00:00
John Bartholomew
6d35a88517 chore: update to Go 1.24.5 to get support for os.Root 2026-02-18 23:06:15 +00:00
John Bartholomew
71c8de23c2 chore: regenerate Bazel files, use go.mod to specify Go SDK version
This brings things more into line with modern conventions for
build target names, and means we have fewer sources of truth for
the minimum Go version that's needed.
2026-02-18 23:06:15 +00:00
John Bartholomew
8dc9acb412 chore: update Bazel, remove WORKSPACE etc, update Bazel lockfile 2026-02-18 22:53:51 +00:00
John Bartholomew
fb23cdf1c0 fix: desugar the index expression of a super[e]
Fixes https://github.com/google/go-jsonnet/issues/679
2026-02-18 17:16:35 +00:00
John Bartholomew
783198bb5d chore: remove Go Releaser archive naming overrides
For https://github.com/google/go-jsonnet/issues/814
2026-02-18 10:29:07 +00:00
John Bartholomew
1dd6e890e5 update cpp-jsonnet to unreleased commit 3560b6d317b127dc901ad4674312bfd12d95a301 2026-02-13 11:58:23 +00:00
John Bartholomew
6c08b4414a import golang golden overrides from cpp-jsonnet
All the go-jsonnet golden output overrides should be kept here in
the go-jsonnet repo. The older override mechanism (in which the
cpp-jsonnet repo has golden files for Golang ending in .golang)
will be removed.
2026-02-09 01:46:36 +00:00
John Bartholomew
0d99c17d4b feat: add flag --no-trailing-newline to prevent adding the trailing newline on outputs
For https://github.com/google/go-jsonnet/issues/518 to allow users to
keep current behaviour for --string --multi, which on go-jsonnet emitted
output without adding an extra newline.

--no-trailing-newline works with all modes except --yaml-stream.
To avoid confusion, the CLI explicitly rejects the combination of both
flags used together.
2026-02-02 23:55:26 +00:00
John Bartholomew
2d72bc599a chore: extract repeated interpreter-construction code from eval functions 2026-02-02 19:01:45 +00:00
Samuel Chan
2946b6ca2e fix: Missing trailing newline when using both --multi and --string options 2026-02-02 18:45:00 +00:00
Mike McRill
264982b4cd
Change FindDependencies to use functional options 2026-02-02 12:23:13 -06:00
Mike McRill
9fab5ebbfe Change FindDependencies to optionally follow symlinks 2026-02-02 11:49:16 -06:00
Thomas Neidhart
f4a8f759ac fix linter to add optional parameters to std.manifestJsonEx 2026-01-30 22:52:02 +00:00
Thomas Neidhart
6890a93743 make linter aware of clamp function 2026-01-30 22:45:42 +00:00
Thomas Neidhart
9635d56406 fix: return null if the provided string to parseYaml did not yield any result 2026-01-30 22:38:41 +00:00
Thomas Neidhart
2629204f7c
fix: handle negative range by returning an empty array 2026-01-30 15:54:40 +01:00
John Bartholomew
fb1ca817d8 chore: run go fmt (except on stdast.go) 2026-01-30 13:54:52 +00:00
John Bartholomew
a8b55c836e add some security notes about imports 2026-01-30 13:51:10 +00:00
John Bartholomew
43845351bc chore: update cpp-jsonnet submodule and stdast 2026-01-29 20:51:42 +00:00
John Bartholomew
8d4b3b72ab reimplement builtinObjectRemoveKey to support inheritance
This follows the same pattern as I used for the C++ implementation.
Flattening the object is probably also possible, but I think it would
involve binding references to 'super' iff they are satisfied by fields
in existing ancestors and leaving them unbound if they're unsatisfied
so that they can be late-bound by extending the output object.

That seems at least as complicated as defining a new form of
uncachedObject to represent a key-removal operation.

For https://github.com/google/go-jsonnet/issues/830
2026-01-29 20:12:46 +00:00
David
c01b909cf1 fix: do not mutate std.removeAt parameters
Resolves google/go-jsonnet#807
2026-01-27 22:21:38 +00:00
John Bartholomew
23a013c3a5 linter: rely on ImportAST internal caching, isolate variables for each snippet 2026-01-27 19:03:49 +00:00
Thomas Neidhart
8893d8e230 Optimize runtime complexity of linter when passing in multiple snippets. 2026-01-27 18:51:09 +00:00
John Bartholomew
a52ac8dceb inline processing of number text into lexNumber 2026-01-27 18:43:46 +00:00
John Bartholomew
a44ee9452f add end to end tests for number literals with underscore digit separators 2026-01-27 18:43:46 +00:00
John Bartholomew
c9f1b48d2d fix underscore handling in numbers to avoid repeated fractions or exponents
See also the corresponding C++ jsonnet commit:
82ebe7de83

There are some cases which are a little strange but lexically valid.

- `1.2.3.4` lexically this tokenises as `1.2` DOT `3.4`, because a dot
  in the fractional or exponent part of a number is simply treated the
  same as any other possible terminating character (any character that
  isn't part of the valid number lexical syntax)
- `1e2.34` lexically is `1e2` DOT `34` (same as the first case)
- `1e2e34` lexically is `1e2` (number) `e34` (identifier)

These behaviours are basically preserved/extrapolated in the case of
digit separators, so for example `1_2.3_4.5_6` is lexically parsed
as `12.34` DOT `56`. And `1e2_3e4` is lexically parsed as
`1e23` (number), `e4` (identifier). These both look very confusing,
but it probably doesn't matter because those token sequences are,
I think, not valid syntactically so they'll just be rejected by
the parser.

Note that in JSON (and jsonnet), leading zeros are not allowed in
numeric literals. This behaviour is explicitly kept with digit
separators, so `0_5` is explicitly rejected. The alternatives are:

- Treat underscore after an initial zero the same as any terminator
  character, so `0_5` lexes as tokens `0` followed by identifier `_5`.
- Allow underscore, thereby breaking the no-leading-zeros rule, so
  `0_5` tokenises as `05`.

Either option seems confusing, hence it seems better to explicitly
reject an underscore after an initial zero.
2026-01-27 18:43:46 +00:00
David Grant
449c302be9 Simpler to not special-case consecutive _s. 2026-01-27 18:43:46 +00:00
David Grant
f664e6d82f Add a test for _123 lexing as identifier. 2026-01-27 18:43:46 +00:00
David Grant
502cac2427 Just use struct literals. 2026-01-27 18:43:46 +00:00
David Grant
1c972d05a2 Add exceptional test cases. Make case table less crazy. 2026-01-27 18:43:46 +00:00