Skip to content

JS CLI ignores --model-config-url and --model-config-path #1404

Description

@fallintoplace

Summary

The JS CLI accepts --model-config-url and --model-config-path, but those values are not forwarded to Magika.create().

In js/magika-cli.ts, Commander defines these flags:

  • --model-config-url <model-config-url>
  • --model-config-path <model-config-path>

With Commander, those options are exposed as flags.modelConfigUrl and flags.modelConfigPath.

However, the CLI currently passes flags.configUrl and flags.configPath into Magika.create(), so the custom config flags are ignored and the default config is used instead.

Evidence

Current CLI wiring on main:

const magika = await Magika.create({
  modelURL: flags.modelUrl,
  modelPath: flags.modelPath,
  modelConfigURL: flags.configUrl,
  modelConfigPath: flags.configPath,
});

Commander exposes the parsed option names as modelConfigUrl / modelConfigPath for these flags. Minimal repro:

const { program } = require("commander");
program.option("--model-config-url <model-config-url>");
program.option("--model-config-path <model-config-path>");
program.parse([
  "node",
  "test",
  "--model-config-url",
  "https://example.invalid/config.json",
  "--model-config-path",
  "/tmp/config.json",
]);
console.log(program.opts());

This prints:

{
  modelConfigUrl: 'https://example.invalid/config.json',
  modelConfigPath: '/tmp/config.json'
}

The JS library itself expects modelConfigURL / modelConfigPath and reads those exact fields in the loader.

Regression history

This looks like a regression introduced during the JS CLI/config rename work:

  • a3c4f6b added JS CLI support for custom model/config loading.
  • aa62093 renamed the JS API fields from config* to modelConfig*.
  • 2be21b1 renamed the CLI flags to --model-config-*, but the code still reads flags.configUrl / flags.configPath.

I also confirmed the bug is present in js-v0.3.1, js-v0.3.2, and current main.

Expected behavior

Passing either --model-config-url or --model-config-path should override the default model config.

Suggested fix

const magika = await Magika.create({
  modelURL: flags.modelUrl,
  modelPath: flags.modelPath,
  modelConfigURL: flags.modelConfigUrl,
  modelConfigPath: flags.modelConfigPath,
});

Testing gap

js/test/magika-cli.test.ts currently covers help/basic execution, but it does not exercise either custom model config flag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions