Skip to content

Python native callbacks with 2+ parameters fail with 'binding parameter a second time' in 0.22.0 #1321

@Moep90

Description

@Moep90

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: <param_name>

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

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:
    # 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: chore: bump jsonnet from 0.21.0 to 0.22.0 kapicorp/kapitan#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions