Python native callbacks with 2+ parameters fail with 'binding parameter a second time' in 0.22.0
- Dominant language
- Jsonnet
- Stars
- 7.6k
- Forks
- 475
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
In jsonnet 0.22.0, Python native callbacks registered with two or more parameters fail at runtime if all parameter names have a length of 2 or more characters. The error is:
```
RUNTIME ERROR: binding parameter a second time:
```
This appears to be a regression introduced in 0.22.0 (likely related to PR #1299 which changed built-in function argument binding).
## Environment
- jsonnet version: 0.22.0
- Python version: 3.13.13 (also reproduced on 3.10+)
- OS: Linux
## Minimal Reproduction
```python
import _jsonnet
def my_func(a, b):
return "{} {}".format(a, b)
# This FAILS in 0.22.0 (worked in 0.21.0)
result = _jsonnet.evaluate_snippet(
"test",
'std.native("my_func")("a", "b")',
native_callbacks={"my_func": (("target", "path"), my_func)}
)
```
Error:
```
RuntimeError: RUNTIME ERROR: binding parameter a second time: path
```
## Observations
1. **Single-parameter callbacks work fine** regardless of name length.
2. **At least one parameter must be 1 character long** for multi-param callbacks to work:
```python
# WORKS (one 1-char param)
(("t", "path"), my_func)
```
3. **The issue affects all multi-param native callbacks**, not just specific names.
4. **This broke existing code** — Kapitan (https://github.com/kapicorp/kapitan) had to shorten parameter names as a workaround: https://github.com/kapicorp/kapitan/pull/1496
## Expected Behavior
Native callbacks with multi-character parameter names should work as they did in 0.21.0.
## Actual Behavior
Runtime error when evaluating any native callback where all parameter names are ≥2 characters.
## Regression Range
- 0.21.0: Works
- 0.22.0: Broken
## Related
- PR #1299 — "Fix some behaviour of builtin functions"
Contributor guide
Assessment
This issue has not been assessed yet.