{"record":{"id":"3ba16f08e4fc88d4","repo":"tracel-ai/burn","slug":"cannot-add-multiple-attributes-when-single-item-is","errorCode":null,"errorMessage":"Cannot add multiple attributes when single item is set.","messagePattern":"Cannot add multiple attributes when single item is set\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-core/src/module/display.rs","lineNumber":422,"sourceCode":"            single_item: None,\n            display_settings,\n            top_level_type: None,\n        }\n    }\n\n    /// Adds an attribute to the format settings. The value will be formatted and stored as a string.\n    ///\n    /// # Arguments\n    ///\n    /// * `name` - Name of the attribute.\n    /// * `value` - Value of the attribute.\n    ///\n    /// # Returns\n    ///\n    /// Updated `Content` instance with the new attribute added.\n    pub fn add<T: ModuleDisplay + ?Sized>(mut self, name: &str, value: &T) -> Self {\n        if self.single_item.is_some() {\n            panic!(\"Cannot add multiple attributes when single item is set.\");\n        }\n\n        let attribute = Attribute {\n            name: name.to_owned(),\n            value: value.format(self.display_settings.clone()), // TODO level + 1\n            ty: any::type_name::<T>().to_string(),\n        };\n        self.attributes.push(attribute);\n        self\n    }\n\n    /// Adds an attribute using its `Debug` representation.\n    ///\n    /// This is intended for fields that do not implement [`ModuleDisplay`].\n    ///\n    /// # Arguments\n    ///\n    /// * `name` - Name of the attribute.","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-core/src/module/display.rs#L404-L440","documentation":"Builder-state invariant violation in the module display system: a `Content` can hold either named attributes (added via `add`) or a single unnamed item (via `add_single`), but not both. This panic fires from `add` when `add_single` was already called on the same builder, i.e. the caller mixed the two mutually exclusive construction styles.","triggerScenarios":"Thrown at crates/burn-core/src/module/display.rs:422 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Build the Content either with `add` for all named attributes or with `add_single` for the one rendered item, never both.","Create a fresh `Content` builder for the single-item case instead of reusing one that already had `add_single` called.","Refactor `custom_content` so each content block has one consistent construction path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}