{"record":{"id":"b56303d92a4ffd2c","repo":"oxc-project/oxc","slug":"alignment-count-must-be-a-non-zero-number","errorCode":null,"errorMessage":"Alignment count must be a non-zero number.","messagePattern":"Alignment count must be a non-zero number\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_formatter_core/src/write/builders.rs","lineNumber":601,"sourceCode":"        f.debug_tuple(\"Dedent\").field(&\"{{content}}\").finish()\n    }\n}\n\n// ---------------------------------------------------------------------------\n// Align\n// ---------------------------------------------------------------------------\n\n/// Aligns its content by indenting the content by `count` spaces.\n///\n/// # Panics\n///\n/// Panics if `count` is `0`.\npub fn align<'ast, C, Content>(count: u8, content: &Content) -> Align<'_, 'ast, C>\nwhere\n    Content: Format<'ast, C>,\n{\n    Align {\n        count: NonZeroU8::new(count).expect(\"Alignment count must be a non-zero number.\"),\n        content: Argument::new(content),\n    }\n}\n\n#[derive(Copy, Clone)]\npub struct Align<'a, 'ast, C> {\n    count: NonZeroU8,\n    content: Argument<'a, 'ast, C>,\n}\n\nimpl<'ast, C> Format<'ast, C> for Align<'_, 'ast, C> {\n    fn fmt(&self, f: &mut Formatter<'_, 'ast, C>) {\n        f.write_element(FormatElement::Tag(StartAlign(tag::Align(self.count))));\n        Arguments::from(&self.content).fmt(f);\n        f.write_element(FormatElement::Tag(EndAlign));\n    }\n}\n","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/oxc-project/oxc/blob/5b3e33548431073728dcf409f0844851804cae0a/crates/oxc_formatter_core/src/write/builders.rs#L583-L619","documentation":"Panic in the formatter's align builder: the count is converted with NonZeroU8::new(count).expect(...), so align(0, ...) is rejected. Zero-space alignment is a no-op and almost always indicates a caller bug, hence the hard failure.","triggerScenarios":"Thrown at crates/oxc_formatter_core/src/write/builders.rs:588 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the align wrapper when no extra indentation is needed","Pass a count of at least 1","Use indent or a NonZeroU8 parameter at the call site to make zero unrepresentable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5b3e33548431073728dcf409f0844851804cae0a","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}