{"record":{"id":"19483c0a604dc8a2","repo":"influxdata/influxdb","slug":"service-limit-values-must-fit-in-a-32-bit-signed-integer-i32","errorCode":null,"errorMessage":"service limit values must fit in a 32-bit signed integer (`i32`)","messagePattern":"service limit values must fit in a 32-bit signed integer \\(`i32`\\)","errorType":"validation","errorClass":"ServiceLimitError","httpStatus":null,"severity":"error","filePath":"core/data_types/src/service_limits.rs","lineNumber":232,"sourceCode":"    /// Requesting an update to the maximum number of columns allowed in each table in this\n    /// namespace\n    MaxColumnsPerTable(MaxColumnsPerTable),\n}\n\n/// Errors converting from raw values to the service limits\n#[derive(Error, Debug, Clone, Copy)]\npub enum ServiceLimitError {\n    /// A negative or 0 value was specified; those aren't allowed\n    #[error(\"service limit values must be greater than 0\")]\n    MustBeGreaterThanZero,\n\n    /// No value was provided so we can't update anything\n    #[error(\"a supported service limit value is required\")]\n    NoValueSpecified,\n\n    /// Limits are stored as `i32` in the database and transferred as i32 over protobuf, so even\n    /// though they are stored as `usize` in Rust, the `usize` value must be less than `i32::MAX`.\n    #[error(\"service limit values must fit in a 32-bit signed integer (`i32`)\")]\n    MustFitInI32,\n\n    /// Per-table column limits are restricted\n    #[error(\n        \"per-table column limits are restricted to a maximum value of {0} for system performance purposes\"\n    )]\n    ColumnLimitTooLarge(MaxColumnsPerTable),\n}\n\nimpl ServiceLimitUpdate {\n    /// Constructs a [`ServiceLimitUpdate`] from the provided `limit_update`,\n    /// performing validation and applying `column_limit_upper_bound` to the\n    /// per-table column limit.\n    pub fn bounded_try_from(\n        limit_update: Option<LimitUpdate>,\n        column_limit_upper_bound: MaxColumnsPerTable,\n    ) -> Result<Self, ServiceLimitError> {\n        match limit_update {","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/data_types/src/service_limits.rs#L214-L250","documentation":"`ServiceLimitError::MustFitInI32` is raised when a limit value stored as `usize` in Rust exceeds `i32::MAX`. Limits are persisted as `i32` in the database and transferred as `i32` over protobuf, so any larger `usize` cannot be represented and would silently truncate or overflow. The library rejects it explicitly during conversion.","triggerScenarios":"Converting a service limit to its stored/protobuf representation with a `usize` value greater than `i32::MAX` (2,147,483,647), e.g. passing `usize::MAX` or a very large configured limit.","commonSituations":"Users setting 'unlimited' as a huge sentinel number; config values copied from 64-bit oriented systems; arithmetic that overflows (multiplying large limits); platform differences where `usize` is 64-bit but the wire format is 32-bit.","solutions":["Reduce the limit value to <= `i32::MAX` before conversion.","If the intent is 'unlimited', use the appropriate sentinel/omission mechanism supported by the schema instead of a huge number.","Use `usize::try_from`/checked conversions with a clamp to `i32::MAX` when computing limits.","Check for accidental overflow in the code that computes the limit."],"exampleFix":"// before\nlet limit: usize = usize::MAX; // sentinel for unlimited\n// after\nlet limit: usize = 2_147_483_647.min(usize::MAX); // must fit i32","handlingStrategy":"validation","validationCode":"fn fits_i32(v: usize) -> bool { v <= i32::MAX as usize }","typeGuard":null,"tryCatchPattern":"let limit = i32::try_from(usize_limit)\n    .map_err(|_| ServiceLimitError::MustFitInI32)?;","preventionTips":["Use `i32::try_from` on every usize->i32 limit conversion","Avoid huge sentinel values for 'unlimited'; use schema-supported omission","Use checked arithmetic when computing limits to prevent overflow"],"tags":["rust","service-limits","integer-overflow"],"backgroundTag":"value-out-of-range","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}