Skip to content

[JS] run() doesn't pass the input to the passed function #3376

@lacolaco

Description

@lacolaco

Describe the bug

run() doesn't pass the input to the passed function.

This is caused by checking arguments.length in the run() implementation. That condition is always falsy.

genkit/js/core/src/flow.ts

Lines 200 to 204 in f18da1f

async (meta) => {
meta.input = input;
const output = arguments.length === 3 ? await func(input) : await func();
meta.output = JSON.stringify(output);
return output;

To Reproduce

    it('should run the action', async () => {
      const act = async () => 'bar';

      const result = await run('action', act, registry);

      assert.equal(result, 'bar'); // => OK
    });

    it('should run the action with input', async () => {
      const act = async (input: string) => `${input} bar`;

      const result = await run('action', 'foo', act, registry);

      assert.equal(result, 'foo bar'); // => ERROR `undefined bar`.
    });

Expected behavior

Tests the above should pass.

Screenshots
If applicable, add screenshots to help explain your problem.

Runtime (please complete the following information):

  • OS: [e.g. Linux, MacOS]
  • Version [e.g. 22]

** Node version

  • run node --version at paste here

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjs

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions