--config-value with a JSON array, number, or string crashes with an internal error
Passing a config value that's valid JSON but not an object crashes with an internal error instead of a config error. Each exits with status 1:
--config-value cfg |
Result |
|---|---|
'[]' |
AttributeError: 'list' object has no attribute 'items' |
'1' |
AttributeError: 'int' object has no attribute 'items' |
'"x"' |
AttributeError: 'str' object has no attribute 'items' |
python flow.py --config-value cfg '[]' showCause
JSON parsing in metaflow/user_configs/config_options.py (~line 388)
succeeds, then ConfigValue in
metaflow/user_configs/config_parameters.py (~line 85) calls .items()
on the result without checking its type.
Expected
A clear config error saying the value for cfg must be a JSON object,
consistent with how other malformed config values are reported.
null currently works through a separate None path and should keep
working as it does today.
Related
#3075 adds a root-type check for its YAML fallback, but that only runs after JSON parsing fails, so it doesn't cover these cases.
Proposed fix
After json.loads, reject any non-None result that isn't a dict with a
config error, preserving the existing null behavior. Add parametrized
tests for arrays, numbers, strings, and null.
Since this touches user_configs/ (Core Runtime), I wanted to confirm
the approach before opening a PR.
Environment
- OS: macOS Tahoe 26.5.2
- Python: 3.12.14
- Metaflow: master (
8b500daa)
Source: Netflix/metaflow