moodle/moodle · error · RuntimeException

merge() expects 1 or more arguments, 0 were provided

Error message

merge() expects 1 or more arguments, 0 were provided

What it means

RuntimeException thrown by fn_merge() when the JMESPath merge() function is called with zero arguments — at least one object argument is required for merging to mean anything.

Solutions

  1. Correct the expression to pass one or more objects to merge()
  2. Lint JMESPath expressions before running them
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at public/lib/jmespath/src/FnDispatcher.php:258 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14). Data as JSON: /api/errors/5ccea0465aaddcd7. Report an issue: GitHub.

Appendix: source

Thrown at public/lib/jmespath/src/FnDispatcher.php:258

        if ($type == 'number') {
            return $value;
        } elseif ($type == 'string' && is_numeric($value)) {
            return mb_strpos($value, '.', 0, 'UTF-8') ? (float) $value : (int) $value;
        } else {
            return null;
        }
    }

    private function fn_values(array $args)
    {
        $this->validate('values', $args, [['array', 'object']]);
        return array_values((array) $args[0]);
    }

    private function fn_merge(array $args)
    {
        if (!$args) {
            throw new \RuntimeException(
                "merge() expects 1 or more arguments, 0 were provided"
            );
        }

        return call_user_func_array('array_replace', $args);
    }

    private function fn_to_array(array $args)
    {
        $this->validate('to_array', $args, [['any']]);

        return Utils::isArray($args[0]) ? $args[0] : [$args[0]];
    }

    private function fn_map(array $args)
    {
        $this->validate('map', $args, [['expression'], ['any']]);
        $result = [];

View on GitHub (pinned to 48ea8c3322)