{"record":{"id":"1b83fd58dbb6d7f7","repo":"louis-e/arnis","slug":"invalid-id","errorCode":null,"errorMessage":"Invalid id","messagePattern":"Invalid id","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/block_definitions.rs","lineNumber":107,"sourceCode":"\n    #[inline(always)]\n    pub const fn id(&self) -> u16 {\n        self.id\n    }\n\n    /// Rebuild a block from a raw id, for the packed section storage.\n    #[inline(always)]\n    pub(crate) const fn from_raw_id(id: u16) -> Self {\n        Self::new(id)\n    }\n\n    #[inline(always)]\n    pub fn namespace(&self) -> &str {\n        \"minecraft\"\n    }\n\n    pub fn name(&self) -> &str {\n        self.try_name().expect(\"Invalid id\")\n    }\n\n    /// Non-panicking variant of `name` (None for unassigned ids).\n    pub fn try_name(&self) -> Option<&str> {\n        Some(match self.id {\n            0 => \"mangrove_log\",\n            1 => \"air\",\n            2 => \"andesite\",\n            3 => \"birch_leaves\",\n            4 => \"birch_log\",\n            5 => \"black_concrete\",\n            6 => \"blackstone\",\n            7 => \"blue_orchid\",\n            8 => \"blue_terracotta\",\n            9 => \"bricks\",\n            10 => \"cauldron\",\n            11 => \"chiseled_stone_bricks\",\n            12 => \"cobblestone_wall\",","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/louis-e/arnis/blob/34048924d9365795fb0d832e76140a3fbdc413d9/src/block_definitions.rs#L89-L125","documentation":"`BlockDescriptor::name()` is a convenience wrapper that calls `try_name()` and panics with \"Invalid id\" via `.expect()` when the block id has no assigned name. The library throws it because `try_name` only maps a fixed table of known ids to names, so any id outside that table (including unassigned/sentinel ids) has no name string to return.","triggerScenarios":"Calling `name()` on a block constructed with an id that is not in the `try_name` match table — e.g. an id read from an unrecognized save/chunk, an out-of-range numeric id, or an unassigned variant. It is hit anywhere `name()` is called: `to_bedrock_block`, `to_bedrock_block_with_properties`, `is_see_through`, `is_trunk`, `is_tree_part`.","commonSituations":"Loading a world file produced by a newer/older version with block ids this build does not know; parsing arbitrary numeric block ids from user input or external data; relying on the default/zero-value id of a struct instead of a real block.","solutions":["Before calling `name()`, call `try_name()` and handle the `None` case instead of unwrapping","Validate the numeric id against the known id range/table before constructing or querying the block","Trace the origin of the bad id (save file, network, default value) and fix the producer so only known ids flow in","Update the library/world data if the id is valid in a newer version of the block table"],"exampleFix":"// before\nlet block_name = block.name();\n// after\nlet block_name = block.try_name().unwrap_or(\"minecraft:air\");","handlingStrategy":"validation","validationCode":"let Some(name) = block.try_name() else { eprintln!(\"unknown block id {}\", block.id()); return; };","typeGuard":"fn is_known_block(b: &BlockDescriptor) -> bool { b.try_name().is_some() }","tryCatchPattern":null,"preventionTips":["Prefer try_name() over name() in all non-test code","Validate block ids from external data against the known table before use","Fuzz-parse world inputs to catch unknown ids early"],"tags":["panic","invalid-id","block-definition"],"backgroundTag":"invalid-enum-discriminant","analyzedSha":"34048924d9365795fb0d832e76140a3fbdc413d9","analyzedAt":"2026-09-03T14:05:17.283Z","contentChangedAt":"2026-09-03T14:05:17.283Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}