Skip to content

v0.6.0

Choose a tag to compare

@github-actions github-actions released this 29 Oct 10:32
· 58 commits to main since this release

Changed

  • Python: get_period gives a zig_hocon.Period, a named tuple of years, months and days (p.months), where it gave a dict; relativedelta(**p._asdict()) gives dateutil's.
  • Python: get_duration and parse_duration raise a ConfigWrongTypeException named Overflow for a duration past 292 years, the longest an int64 of nanoseconds holds, where they gave 292 years without a word (C's hocon_get_duration_ns saturates there, as before).
  • Python: the README and the package description no longer call the API pyhocon's. Only parse_file, parse_string, the typed getters and the exception names carry over; code that uses the tree as a dict, reads lists or calls pyhocon's other methods is rewritten, as MIGRATING.md says.
  • Optional substitutions on a cycle resolve the same whichever field comes first, as the spec has it, where v0.5.3 dropped or kept them by the order of the lines, and in two cases lost a value: b.c += ${y}, b.c += 2, y = [1, ${?b}] is b.c = [[1], 2] again, and f = x${?a}, f = { z = 3 }, a = ${?f} keeps a, since text under an object is hidden and never evaluated, as a list is. An include inside an object concatenated with an optional, k = { include "x" } ${?y}, no longer reports a cycle. Found by a bug hunt on v0.5.3.
  • Four regressions in that change, found by a bug hunt on it, are fixed. A field written twice and reached again from inside a look-back, d { z = ${?a.k} }, d.z += ${?c}, a : [], a += ${f}, f = ${d}, crashed with reached unreachable code and resolves again, as typesafe/config has it; an undefined ${b} in such a field, a crash already in v0.5.3, is the Unresolved error. f += ${?b}, b = x${?f}, b += 1 dropped b's text and gave b = [1], and is the error += onto text is, whichever line comes first. e = [${?f.k}y], f = ${?e}${e} and e.k : ${?b}, b.k { k = ${?e}, k += ${?d} } resolve the same in either order: an optional found to lead back to its own field stays nonexistent when it is met again. Ten new conformance cases, all passing.
  • d.z += 5 reached again through a field that copies d, d { z = ${?a.k} }, a : [], a += ${d}, appended 5 twice, [5, 5], when d was written before a, while the copy in a held [5]; it is [5] in every order, as the spec has it.

Added

  • hocon --env-file=<file>, on every command and check --schema too: the KEY=value lines of a file over the environment, a later file over an earlier one, over none with --env=none; the lines zig-hocon-migrate --env-file reads.
  • Python: zig_hocon.__version__, the version the package was built as.
  • Python: zig_hocon.parse_int and zig_hocon.parse_bool read a number and a boolean as get_int, get_bool and a Zig struct do, for a model's validator: a lax pydantic model takes "08" as 8 and "True", which the Zig side of the same application refuses.
  • Python: zig_hocon.parse_period("3 months") gives what get_period does, for a model's validator, beside parse_duration and parse_bytes.
  • The CLI is fuzzed on every pull request and branch push (.github/workflows/fuzz.yml): tools/fuzz/fuzz.py --no-java --fail-on-crash, a crash or a hang fails the run. A pull request's wheels are X.Y.Z+g<commit>, which PyPI refuses; CONTRIBUTING.md says what a patch and a minor release may change.
  • Python: pip install zig-hocon puts the hocon command line tool of its platform on the path, the same as a release's, with get, diff and check; only check --schema, which builds a Zig program and needs zig, is left out.
  • Python: zig-hocon-migrate conf/ (pip installs it; python -m zig_hocon migrate is the same) reads each config with pyhocon and with zig-hocon, with the same environment, and shows where they differ as the config's tree: another type a getter reads the same, another value, or one of them failing. A directory is its entry points; it exits 1 when anything differs, for CI, and --json gives the tree as JSON. --fallback reference.conf reads each config over a reference as conf.with_fallback(reference) in a loader does, --getters makes a value a getter reads the same no difference, --accept PATH marks a reviewed difference as no difference, --resolve-each reads as a loader that resolves each file before the merge, and --before main has pyhocon read the configs as they are on main and zig-hocon as they are now, so the run can gate CI.
  • Python: MIGRATING.md says that x += [3, 4] appends the list as one element, by the spec, where pyhocon extends the list; it said += reads the same.

Fixed

  • Python: parse_duration, parse_bytes and the other parse_* helpers given no text or number (True, a list) raise an error that is a ValueError as well as the TypeError it was, so a pydantic validator reports it as the field's error instead of letting a bare TypeError through; an Overflow says what it was given, not v.
  • Diagnostics.render names the file when the file a parse was given cannot be read, prod.conf: error: FileNotFound, where it printed error: FileNotFound alone; the new field Diagnostics.file holds it.
  • d { z = ${?a.k} }, d.z += 5, a += ${d} was a SubstitutionCycle when d came before a, and {d: {z: [5]}, a: [{z: [5]}]} in the other orders: the ${?a.k} that leads back to d.z is nonexistent (spec L716) in every order now, as typesafe/config reads it. v0.5.3 had it too; two conformance cases more, 588 in all.
  • Python: a getter that cannot read a value notes what it read, which a traceback prints under the message (Python 3.11+): found '08', where a ${…} from the environment showed only its name.
  • Python: copy.copy and copy.deepcopy of a ConfigTree failed with a TypeError on the library's handle, and an error from the handle's cleanup; a tree is read only, so a copy is now the tree itself.
  • Python: help(), pydoc and an IDE showed the whole process environment, secrets too, in the signature of ConfigFactory.parse_file and parse_string, whose default env was os.environ itself. The default is now named os.environ and reads it at the call, as before.
  • A NUL or another control character in unquoted text was written back by to_hocon / hocon --hocon as it was, and a NUL ended the text for C and Python: motd = hello<NUL>world lost every key after it. Such text is written quoted now, the character escaped ("hello\u0000world").
  • A parse through libhocon (C, Python) sets SIGIO and SIGPIPE only while it fetches an http(s) include, which needs them, and puts back the handlers from before when the last such parse ends: a handler the program set, Python's signal.signal(SIGIO, …) among them, stays its own.
  • A deep document on a thread with little stack, a Python thread or one of musl's 128 KiB, ended the process with SIGBUS or SIGSEGV before the limit of 500 levels: libhocon parses and writes on a thread of its own with 16 MiB of stack, so a deeper document is TooDeep on any thread, and one below the limit is read.
  • An include whose file cannot be read reports why: include url("http://…") with a host past 255 bytes no longer aborts the process (NameTooLong), HTTP:// is fetched like http://, a path through a file (x.conf/y.conf) is a missing include and so ignored, and a symlink to itself is SymLinkLoop, not an include cycle that is not there.
  • A value concatenating many substitutions, a = ${x} ${x} …, resolves in memory linear in its length: 16 000 one-element lists took 3.9 GB and now take 18 MB, 32 000 strings 2.95 GB and now 24 MB.