{"record":{"id":"b3fbec48768ddb02","repo":"pydantic/monty","slug":"function-not-found","errorCode":null,"errorMessage":"Function not found","messagePattern":"Function not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/monty/src/intern.rs","lineNumber":1661,"sourceCode":"\n    /// Looks up a long integer by its `LongIntId`.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the `LongIntId` is invalid.\n    #[inline]\n    pub fn get_long_int(&self, id: LongIntId) -> &BigInt {\n        self.long_ints[id.index()].value()\n    }\n\n    /// Lookup a function by its `FunctionId`\n    ///\n    /// # Panics\n    ///\n    /// Panics if the `FunctionId` is invalid.\n    #[inline]\n    pub fn get_function(&self, id: FunctionId) -> &Function {\n        self.functions.get(id.index()).expect(\"Function not found\")\n    }\n\n    /// Injects `fault` into the named function's metadata.\n    #[cfg(feature = \"test-hooks\")]\n    pub(crate) fn corrupt_function_metadata_for_tests(&mut self, name: &str, fault: FunctionMetadataFault) {\n        let index = self\n            .functions\n            .iter()\n            .position(|function| self.get_str(function.name.name_id) == name)\n            .unwrap_or_else(|| panic!(\"test function '{name}' not found\"));\n        self.functions[index].corrupt_metadata_for_tests(fault);\n    }\n\n    /// Returns the Python hash for an interned string.\n    ///\n    /// Dispatches by id range:\n    /// * ASCII (`id < 128`): looks up [`ASCII_HASHES`] (per-slot lazy);\n    ///   computes via [`hash_python_str`] on first use of that byte.","sourceCodeStart":1643,"sourceCodeEnd":1679,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty/src/intern.rs#L1643-L1679","documentation":"`get_function` indexes the functions vec with `FunctionId` and panics if the id is out of bounds. `FunctionId`s are only ever produced by the same intern table, so this documents the invariant that a live `FunctionId` always has a matching entry.","triggerScenarios":"Calling `get_function` with a `FunctionId` whose index is >= `functions.len()` — e.g. an id from a different/dropped table, a corrupted id, or a deserialization bug.","commonSituations":"Mixing ids across two `InternTable` instances, loading bytecode compiled by an incompatible version, or heap corruption.","solutions":["Ensure `FunctionId` values are used only with the table that produced them.","Verify version compatibility when deserializing compiled functions.","Report as a bug if triggered within a single table's lifetime."],"exampleFix":"// before\nself.functions.get(id.index()).expect(\"Function not found\")\n// after\nself.functions.get(id.index())\n    .ok_or_else(|| InternalError::MissingFunction(id))?","handlingStrategy":"validation","validationCode":"assert!(function_id.index() < table.function_count(), \"FunctionId out of range\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use ids with the table that issued them","Version-check deserialized bytecode","Report cross-table id mixing as a bug"],"tags":["rust","panic","bytecode"],"backgroundTag":"internal-invariant-violation","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}