Skip to content

Command-line configuration values arrive as strings, so a numeric knob set there breaks arithmetic #359

Description

@MartinEbner

Describe the bug

The same configuration key resolves to a different Python type depending on which source it comes
from.

src/config.py:

def command_line_to_dict(list):
    for arg in list:
        kv = arg.split("=", 1)
        if len(kv) == 2:
            dict[kv[0]] = kv[1]        # always a string
        else:
            dict[kv[0]] = True         # a bare argument becomes a bool

The config file goes through yaml.safe_load, so maxFeedback: 25000 yields the integer 25000,
while maxFeedback=25000 on the command line yields the string "25000". config_get_by_key
passes either through unchanged, and configure stores whatever it gets into the atomspace. Any
later arithmetic on the value then fails, because a string reaches the Prolog evaluator as a
symbol rather than a number.

Command-line overrides are documented in docs/reference-configuration.md ("This reads a
command-line override via argk (name=value …)"), with no restriction to string-valued keys, so
the two sources look interchangeable.

To Reproduce

  1. Start the agent with a numeric knob on the command line, for example
    run.metta maxFeedback=25000.
  2. The boot aborts while evaluating the knob. On our deployment the line was
    is/2: Arithmetic: 25000/0 is not a function — the Name/Arity form, i.e. the value had
    become a symbol.
  3. Move the same value into config/config.yaml and the boot succeeds.

A related case in the same function: a bare argument without = becomes Python True, so
maxFeedback typed without a value is accepted as a boolean rather than rejected as a missing
value.

Expected behavior

A key resolves to the same value whichever source supplies it, or the command line rejects values
it cannot represent.

Actual behavior

A numeric knob works from config.yaml and aborts the boot from the command line, with an error
that names the value but not the cause.

Possible fix

Coerce in one place — in command_line_to_dict or config_get_by_key, try int, then float,
and fall back to the string. That keeps string knobs untouched and makes the two sources agree.
If command-line overrides are meant to be string-only, documenting that in
reference-configuration.md would also close it.

Environment

Seen on our own deployment while moving knobs from the launch line into config.yaml. The code
path above is current main, and it sits in the configuration layer, so it is independent of OS,
provider and channel.

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