{"record":{"id":"f253a9a5f8f18370","repo":"nautechsystems/nautilus_trader","slug":"default-portfolioconfig-should-be-valid","errorCode":null,"errorMessage":"default `PortfolioConfig` should be valid","messagePattern":"default `PortfolioConfig` should be valid","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/portfolio/src/config.rs","lineNumber":145,"sourceCode":"                errors.check(\n                    ms > 0,\n                    ConfigError::range(\n                        field,\n                        format!(\"must be a positive number of milliseconds, was {ms}\"),\n                    ),\n                );\n            }\n        }\n\n        errors.into_result()\n    }\n}\n\nimpl Default for PortfolioConfig {\n    fn default() -> Self {\n        Self::builder()\n            .build()\n            .expect(\"default `PortfolioConfig` should be valid\")\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use rstest::rstest;\n\n    use super::*;\n\n    #[rstest]\n    fn test_default_config_is_valid() {\n        assert!(PortfolioConfig::builder().build().is_ok());\n    }\n\n    #[rstest]\n    fn test_default_config_enables_daily_equity_curve_only() {\n        let config = PortfolioConfig::default();\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/portfolio/src/config.rs#L127-L163","documentation":"Default for PortfolioConfig builds via the typed builder and unwraps, asserting the library's own defaults satisfy all builder validation rules. This panic indicates a library bug: the default configuration became invalid relative to its builder invariants.","triggerScenarios":"Calling PortfolioConfig::default() (directly or via ..Default::default() in configs) — panics only if the builder rejects the default field values, e.g. after a version change introduced new validated fields.","commonSituations":"Mixing crate versions (model/portfolio mismatch) where defaults no longer satisfy validation; a regression in the portfolio crate after adding a new required/validated config option.","solutions":["Update all nautilus crates to a consistent version (cargo update).","Reproduce with an explicit builder call to see which field fails validation.","Report as a library bug — the default must always be valid."],"exampleFix":"// before\nlet config = PortfolioConfig::default(); // panics if defaults invalid\n// after\nlet config = PortfolioConfig::builder()\n    .build()\n    .unwrap_or_else(|e| panic!(\"portfolio default invalid: {e}\")); // inspect the failing field","handlingStrategy":"validation","validationCode":"// verify builder validity explicitly to surface the failing field\nlet cfg = PortfolioConfig::builder().build();\nif let Err(e) = &cfg { eprintln!(\"portfolio config invalid: {e}\"); }","typeGuard":null,"tryCatchPattern":"let result = std::panic::catch_unwind(PortfolioConfig::default);","preventionTips":["Keep all nautilus crate versions aligned","Prefer explicit builder construction in tests to see validation errors","Report defaults that fail validation as upstream bugs"],"tags":["rust","config","builder","default","portfolio"],"backgroundTag":"invalid-config-value","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"}