Project
cortex
Description
In config_override.rs (lines 34-44), the -c key=value parser tries i64::parse() then f64::parse() before falling back to String. Any value that looks numeric is silently coerced. A user setting port=8080 gets toml::Value::Integer(8080) even if the config schema expects a string. Setting version=1.0 gets toml::Value::Float(1.0) even if it should be "1.0".
Error Message
Debug Logs
System Information
Operating System: Windows 10
Version: 0.0.7
Screenshots
Steps to Reproduce
PS E:\Workspace\Work History\SN100\cortex> cargo run --bin cortex -- run -c "api_port=8080" -c "version=1.0"
Expected Behavior
When the TOML config schema defines api_port as a string, the value "8080" should remain a string. The user should be able to force string type with quotes: -c 'api_port="8080"'.
Actual Behavior
Config override: api_port = 8080 (integer)
Config override: version = 1.0 (float)
[ERROR] Type mismatch for 'api_port': expected string, got integer
The coercion happens unconditionally at parse time (line 38-41) with no escape mechanism. Users cannot pass numeric-looking strings via -c. The only workaround is editing the TOML file directly.
// Line 38-41: Always coerces before checking schema
} else if let Ok(num) = value_str.parse::() {
toml::Value::Integer(num) // "8080" → Integer(8080)
} else if let Ok(num) = value_str.parse::() {
toml::Value::Float(num) // "1.0" → Float(1.0)
Additional Context
File: config_override.rs (Lines 38-41)
Root Cause: Type coercion is eager and unconditional. No mechanism to escape numeric values as strings (e.g., quoting). Should either respect the target schema type or allow explicit quoting like -c 'port="8080"'.
Project
cortex
Description
In config_override.rs (lines 34-44), the -c key=value parser tries i64::parse() then f64::parse() before falling back to String. Any value that looks numeric is silently coerced. A user setting port=8080 gets toml::Value::Integer(8080) even if the config schema expects a string. Setting version=1.0 gets toml::Value::Float(1.0) even if it should be "1.0".
Error Message
Debug Logs
System Information
Screenshots
Steps to Reproduce
PS E:\Workspace\Work History\SN100\cortex> cargo run --bin cortex -- run -c "api_port=8080" -c "version=1.0"
Expected Behavior
When the TOML config schema defines api_port as a string, the value "8080" should remain a string. The user should be able to force string type with quotes: -c 'api_port="8080"'.
Actual Behavior
Config override: api_port = 8080 (integer)
Config override: version = 1.0 (float)
[ERROR] Type mismatch for 'api_port': expected string, got integer
The coercion happens unconditionally at parse time (line 38-41) with no escape mechanism. Users cannot pass numeric-looking strings via -c. The only workaround is editing the TOML file directly.
// Line 38-41: Always coerces before checking schema
} else if let Ok(num) = value_str.parse::() {
toml::Value::Integer(num) // "8080" → Integer(8080)
} else if let Ok(num) = value_str.parse::() {
toml::Value::Float(num) // "1.0" → Float(1.0)
Additional Context
File: config_override.rs (Lines 38-41)
Root Cause: Type coercion is eager and unconditional. No mechanism to escape numeric values as strings (e.g., quoting). Should either respect the target schema type or allow explicit quoting like -c 'port="8080"'.