jow- / ucode

JavaScript-like language with optional templating
ISC License
90 stars 30 forks source link

uci: auto-load package in `ctx.foreach()` and `ctx.get_first()` #126

Closed jow- closed 1 year ago

jow- commented 1 year ago

Functions that use uci_lookup_ptr() internally, such as ctx.get(), ctx.set() or ctx.delete(), implicitly load the given configuration name while the higher level functions ctx.foreach() or ctx.get_first() do not.

This behaviour violates the principle of least surprise and might lead to non-deterministic program behavior as the outcome of these functions depends on prior uci operations performed on the cursor.

Fix this issue by invoking uci_load() internally in case the given uci package name cannot be found in the cursor's package cache.

Signed-off-by: Jo-Philipp Wich jo@mein.io