{"record":{"id":"bf71a3af719f0f48","repo":"diesel-rs/diesel","slug":"diesel-max-column-count-is-a-number-that-fits-into","errorCode":null,"errorMessage":"DIESEL_MAX_COLUMN_COUNT is a number that fits into a u16","messagePattern":"DIESEL_MAX_COLUMN_COUNT is a number that fits into a u16","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diesel/src/internal/table_macro.rs","lineNumber":48,"sourceCode":"#[doc(hidden)]\npub use crate::query_source::private::{Pick, PlainQuerySource, Sealed};\n\n#[doc(hidden)]\npub mod ops {\n    #[doc(hidden)]\n    pub use crate::expression::ops::numeric::*;\n}\n\n#[doc(hidden)]\npub use crate::expand_mysql_like;\n#[doc(hidden)]\npub use crate::expand_pg;\n#[doc(hidden)]\n#[cfg(feature = \"custom-count-column-tables\")]\npub const MAX_COLUMN_COUNT: u16 = {\n    let number = env!(\"DIESEL_MAX_COLUMN_COUNT\");\n    let Ok(n) = u16::from_str_radix(number, 10) else {\n        panic!(\"DIESEL_MAX_COLUMN_COUNT is a number that fits into a u16\");\n    };\n    n\n};\n#[doc(hidden)]\n#[cfg(all(\n    not(feature = \"custom-count-column-tables\"),\n    feature = \"128-column-tables\"\n))]\npub const MAX_COLUMN_COUNT: u16 = 128;\n#[doc(hidden)]\n#[cfg(all(\n    not(feature = \"custom-count-column-tables\"),\n    not(feature = \"128-column-tables\"),\n    feature = \"64-column-tables\"\n))]\npub const MAX_COLUMN_COUNT: u16 = 64;\n#[doc(hidden)]\n#[cfg(all(","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel/src/internal/table_macro.rs#L30-L66","documentation":"This is a compile-time const-evaluation panic in diesel's table macro support. When the `custom-count-column-tables` feature is enabled, diesel reads the `DIESEL_MAX_COLUMN_COUNT` environment variable at compile time and parses it as a u16; if the value is missing or not a decimal number that fits in a u16, the const block panics and the build fails. It exists to validate the max-column-count configuration the table! macro relies on.","triggerScenarios":"Compiling a crate with feature `custom-count-column-tables` enabled while the `DIESEL_MAX_COLUMN_COUNT` env var at build time is absent, non-numeric, negative, or greater than 65535, so `u16::from_str_radix` fails and the const block panics.","commonSituations":"Developers raising the column limit set DIESEL_MAX_COLUMN_COUNT to a value like 100000 (> u16::MAX), typo it (e.g. \"32x\"), or set it in .cargo/config.toml / CI for one build profile but not another. Upgrading diesel and newly enabling the feature without setting the env var also triggers it.","solutions":["Set DIESEL_MAX_COLUMN_COUNT to a decimal integer between 0 and 65535 in the build environment (e.g. DIESEL_MAX_COLUMN_COUNT=64 cargo build).","Check .cargo/config.toml [env] sections and CI matrices so every build profile that enables custom-count-column-tables exports the variable.","If you don't actually need custom column counts, disable the `custom-count-column-tables` feature so the const block isn't compiled.","Confirm the value contains only ASCII digits with no sign, spaces, or thousands separators."],"exampleFix":"// before (build env)\nDIESEL_MAX_COLUMN_COUNT=100000 cargo build   // exceeds u16::MAX -> compile-time panic\n\n// after\nDIESEL_MAX_COLUMN_COUNT=65535 cargo build","handlingStrategy":"validation","validationCode":"// shell, before building\nn=\"${DIESEL_MAX_COLUMN_COUNT}\"\nif ! [[ \"$n\" =~ ^[0-9]+$ ]] || [ \"$n\" -gt 65535 ]; then echo \"DIESEL_MAX_COLUMN_COUNT must be a u16\"; exit 1; fi","typeGuard":"fn is_valid_max_column_count(v: &str) -> bool { v.parse::<u16>().is_ok() }","tryCatchPattern":null,"preventionTips":["Always set DIESEL_MAX_COLUMN_COUNT in .cargo/config.toml [env] alongside enabling custom-count-column-tables.","Keep the value <= 65535; document the u16 constraint in your build docs.","CI-lint the env value with a parse::<u16> check before compiling."],"tags":["compile-time","env-var","build-configuration","diesel"],"backgroundTag":"invalid-env-var-value","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}