{"record":{"id":"42da6f242aef1742","repo":"pydantic/monty","slug":"bytesid-overflow","errorCode":null,"errorMessage":"BytesId overflow","messagePattern":"BytesId overflow","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/monty/src/intern.rs","lineNumber":1413,"sourceCode":"    /// * If the string was already interned, returns the existing string id\n    /// * Otherwise, stores the string and returns a new string id\n    pub fn intern(&mut self, s: &str) -> StringId {\n        intern_str(&mut self.string_map, &mut self.strings, s)\n    }\n\n    /// Looks up the `StringId` for a string already interned (or ascii/static).\n    ///\n    /// Mirrors [`Interns::get_string_id_by_name`] so the compiler can resolve\n    /// builtin names before the runtime table is built.\n    pub fn get_string_id_by_name(&self, s: &str) -> Option<StringId> {\n        get_string_id_by_name(&self.string_map, s)\n    }\n\n    /// Interns bytes, returning its `BytesId`.\n    ///\n    /// Unlike interns, bytes are not deduplicated (bytes literals are rare).\n    pub fn intern_bytes(&mut self, b: &[u8]) -> BytesId {\n        let id = BytesId(self.bytes.len().try_into().expect(\"BytesId overflow\"));\n        self.bytes.push(WithHash::for_bytes(b.to_vec()));\n        id\n    }\n\n    /// Interns a long integer, returning its `LongIntId`.\n    ///\n    /// Big integers are not deduplicated since literals exceeding i64 are rare.\n    pub fn intern_long_int(&mut self, bi: BigInt) -> LongIntId {\n        let id = LongIntId(self.long_ints.len().try_into().expect(\"LongIntId overflow\"));\n        self.long_ints.push(WithHash::for_long_int(bi));\n        id\n    }\n\n    /// Looks up a string by its `StringId`.\n    #[inline]\n    pub fn get_str(&self, id: StringId) -> &str {\n        get_str(&self.strings, id)\n    }","sourceCodeStart":1395,"sourceCodeEnd":1431,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty/src/intern.rs#L1395-L1431","documentation":"An internal overflow guard in `Interns::intern_bytes`, which assigns sequential `BytesId`s to interned byte strings. The assertion fires if the interned-bytes table grows beyond the `BytesId` representation limit — i.e. more distinct byte objects than the id space allows within a single compilation/execution. It is effectively unreachable for real workloads; it exists so exhaustion is a clear panic rather than silent id wraparound.","triggerScenarios":"Thrown at crates/monty/src/intern.rs:1413 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Interning a byte string exceeded the StringId/BytesId capacity (index space exhausted); typical fix is widening the id type or enforcing an explicit intern limit before allocation.","Callers cannot recover mid-compilation: the table indexes are baked into bytecode; the error should abort compilation with a clear resource-limit message rather than be retried.","Prevent by bounding the number of distinct byte strings accepted per compilation via ResourceLimits."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}