{"record":{"id":"d350ad672be0d0de","repo":"BoundaryML/baml","slug":"read-capacity-must-fit-inside-normal-capacity","errorCode":null,"errorMessage":"read capacity must fit inside normal capacity","messagePattern":"read capacity must fit inside normal capacity","errorType":"validation","errorClass":"LimitsError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp_server/src/lsp_ingress.rs","lineNumber":262,"sourceCode":"            normal_bytes: 4 * 1024 * 1024,\n            reserved_items: 64,\n            reserved_bytes: 2 * 1024 * 1024,\n            read_items: 128,\n            read_bytes: 2 * 1024 * 1024,\n            control_items: 64,\n            control_bytes: 64 * 1024,\n            outbound_response_items: 256,\n            outbound_response_bytes: 4 * 1024 * 1024,\n            response_reservation_bytes: 16 * 1024,\n        }\n    }\n}\n\n#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]\npub enum LimitsError {\n    #[error(\"all ingress capacities and the response reservation must be non-zero\")]\n    ZeroCapacity,\n    #[error(\"read capacity must fit inside normal capacity\")]\n    ReadExceedsNormal,\n    #[error(\"one response reservation must fit in the outbound byte capacity\")]\n    ResponseReservationTooLarge,\n    #[error(\"combined normal and reserved capacity overflowed usize\")]\n    CapacityOverflow,\n}\n\nimpl IngressLimits {\n    fn validate(self) -> Result<Self, LimitsError> {\n        if self.normal_items == 0\n            || self.normal_bytes == 0\n            || self.reserved_items == 0\n            || self.reserved_bytes == 0\n            || self.read_items == 0\n            || self.read_bytes == 0\n            || self.control_items == 0\n            || self.control_bytes == 0\n            || self.outbound_response_items == 0","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp_server/src/lsp_ingress.rs#L244-L280","documentation":"`LimitsError::ReadExceedsNormal`. The read capacity (reserved for a single in-flight message read) must fit inside the normal capacity; otherwise the read path could claim more than the ingress can hold. Validation rejects such limits.","triggerScenarios":"Constructing `IngressLimits` where the read byte capacity (or read item capacity) is larger than the corresponding normal capacity, then validating.","commonSituations":"Tuning the read window up for large messages without raising the normal capacity; confusing the two parameters' order in a constructor call; copying limits between services with different units.","solutions":["Increase the normal capacity so it is at least the read capacity","Decrease the read capacity to fit within normal capacity","Double-check constructor argument order (read vs normal) when building limits","Add a startup assertion that read <= normal for your configured values"],"exampleFix":"// before: read exceeds normal\nlet limits = IngressLimits::new(normal_items, 1 << 12, /*read*/ 1 << 20, 1 << 10)?;\n\n// after: read fits inside normal\nlet limits = IngressLimits::new(normal_items, 1 << 20, /*read*/ 1 << 12, 1 << 10)?;","handlingStrategy":"validation","validationCode":"fn read_fits(l_read: usize, l_normal: usize) -> bool { l_read <= l_normal }","typeGuard":null,"tryCatchPattern":"let read = read.min(normal);\nlet limits = IngressLimits::new(items, normal_bytes, read, reservation)?;","preventionTips":["Derive read capacity as a fraction of normal capacity","Double-check parameter order when constructing limits","Assert read <= normal in tests around limit configuration"],"tags":["lsp","rust","validation","limits"],"backgroundTag":"invalid-config-value","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}