{"record":{"id":"41efbcfee454627f","repo":"nautechsystems/nautilus_trader","slug":"canonical-run-configuration-id-must-be-a-string-or","errorCode":null,"errorMessage":"canonical run configuration ID must be a string or null","messagePattern":"canonical run configuration ID must be a string or null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/backtest/src/result.rs","lineNumber":452,"sourceCode":"            \"total_positions\",\n            \"trader_id\",\n        ],\n        \"canonical result run\",\n    )?;\n\n    for key in [\n        \"iterations\",\n        \"total_events\",\n        \"total_orders\",\n        \"total_positions\",\n    ] {\n        validate_unsigned_decimal(object.get(key).expect(\"validated field\"), key, false)?;\n    }\n\n    for key in [\"backtest_start_ns\", \"backtest_end_ns\"] {\n        validate_unsigned_decimal(object.get(key).expect(\"validated field\"), key, true)?;\n    }\n    anyhow::ensure!(\n        object\n            .get(\"run_config_id\")\n            .is_some_and(|value| value.is_null() || value.is_string()),\n        \"canonical run configuration ID must be a string or null\"\n    );\n    anyhow::ensure!(\n        object.get(\"trader_id\").is_some_and(Value::is_string),\n        \"canonical trader ID must be a string\"\n    );\n    anyhow::ensure!(\n        matches!(\n            object.get(\"outcome\").and_then(Value::as_str),\n            Some(\"completed\" | \"failed\" | \"incomplete\" | \"stopped\")\n        ),\n        \"unsupported canonical run outcome\"\n    );\n    Ok(())\n}","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/result.rs#L434-L470","documentation":"This error comes from `validate_run` in the backtest result module, which enforces the schema of the canonical (serialized) backtest result document. The `run_config_id` field of the `run` object must be either a JSON string or JSON null — anything else (number, boolean, missing-then-checked, array, object) is rejected. It exists so downstream consumers of the canonical document can rely on a stable, typed identifier for the run configuration.","triggerScenarios":"Calling `validate_document` on a canonical result JSON whose `run.run_config_id` is a non-string, non-null JSON value (e.g. an integer, an object, or an array). This happens when the document was produced by an older/other serializer or hand-edited rather than emitted by this library's canonical writer.","commonSituations":"Migrating results produced by a previous schema version where run_config_id was encoded as a number; hand-crafting or post-processing result JSON with a script that coerces the ID to a number; loading fixture files from a different codebase version.","solutions":["Ensure run_config_id is serialized as a string (or explicit null when no config ID exists)","Re-generate the canonical result document with the current version of the library instead of reusing old artifacts","Validate the JSON before passing it to validate_document and coerce non-string IDs to strings with String(value)","Check that no post-processing step (jq, Python script) rewrote the field type"],"exampleFix":"// before\n{\"run\": {\"run_config_id\": 12345, ...}}\n// after\n{\"run\": {\"run_config_id\": \"12345\", ...}}","handlingStrategy":"validation","validationCode":"fn run_config_id_is_valid(run: &serde_json::Value) -> bool {\n    run.get(\"run_config_id\")\n        .is_some_and(|v| v.is_null() || v.is_string())\n}","typeGuard":"fn is_string_or_null(v: &serde_json::Value) -> bool {\n    v.is_null() || v.is_string()\n}","tryCatchPattern":"match validate_document(&doc) {\n    Err(e) if e.to_string().contains(\"run configuration ID\") => {\n        // coerce run.run_config_id to string or null and retry\n    }\n    other => other,\n}","preventionTips":["Always serialize run_config_id as a string or explicit null","Use the library's canonical writer rather than hand-building result JSON","Pin and check the result document schema version before validating","Avoid numeric coercion of IDs in post-processing scripts"],"tags":["json","validation","schema","backtest"],"backgroundTag":"schema-validation-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}