{"record":{"id":"4fe047643165dd59","repo":"moodle/moodle","slug":"prefix-not-allowed-for-uom","errorCode":null,"errorMessage":"Prefix not allowed for UoM","messagePattern":"Prefix not allowed for UoM","errorType":"validation","errorClass":"PhpOffice\\PhpSpreadsheet\\Calculation\\Exception","httpStatus":null,"severity":"error","filePath":"public/lib/phpspreadsheet/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php","lineNumber":589,"sourceCode":"\n        return ($baseValue * self::$unitConversions[$fromCategory][$toUOM]) / $toMultiplier;\n    }\n\n    /** @return array{0: string, 1: string, 2: float} */\n    private static function getUOMDetails(string $uom): array\n    {\n        if (isset(self::$conversionUnits[$uom])) {\n            $unitCategory = self::$conversionUnits[$uom]['Group'];\n\n            return [$uom, $unitCategory, 1.0];\n        }\n\n        // Check 1-character standard metric multiplier prefixes\n        $multiplierType = substr($uom, 0, 1);\n        $uom = substr($uom, 1);\n        if (isset(self::$conversionUnits[$uom], self::$conversionMultipliers[$multiplierType])) {\n            if (self::$conversionUnits[$uom]['AllowPrefix'] === false) {\n                throw new Exception('Prefix not allowed for UoM');\n            }\n            $unitCategory = self::$conversionUnits[$uom]['Group'];\n\n            return [$uom, $unitCategory, self::$conversionMultipliers[$multiplierType]['multiplier']];\n        }\n\n        $multiplierType .= substr($uom, 0, 1);\n        $uom = substr($uom, 1);\n\n        // Check 2-character standard metric multiplier prefixes\n        if (isset(self::$conversionUnits[$uom], self::$conversionMultipliers[$multiplierType])) {\n            if (self::$conversionUnits[$uom]['AllowPrefix'] === false) {\n                throw new Exception('Prefix not allowed for UoM');\n            }\n            $unitCategory = self::$conversionUnits[$uom]['Group'];\n\n            return [$uom, $unitCategory, self::$conversionMultipliers[$multiplierType]['multiplier']];\n        }","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/moodle/moodle/blob/48ea8c33227277e916cdd4079dbecef448b37f2c/public/lib/phpspreadsheet/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php#L571-L607","documentation":"CONVERTUOM's helper getUOMDetails() failed to resolve the unit-of-measure string: it was not found in the conversion table, and after stripping a leading character as a metric prefix, the remaining unit either is not a known unit or the prefix is not a valid metric multiplier for that unit's group. Since prefixes only apply to units that permit them, this input is rejected with an Exception (surfaced as an Excel error) — i.e. a malformed or unsupported 'from'/'to' UoM argument.","triggerScenarios":"Thrown at public/lib/phpspreadsheet/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php:589 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a recognized unit code from PhpSpreadsheet's CONVERT unit tables","Only attach metric prefixes (k, M, G, m, u, n, ...) to units whose group allows prefixes (e.g. gram, meter)","Check for typos or stray characters in the UoM string (case-sensitive codes)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"48ea8c33227277e916cdd4079dbecef448b37f2c","analyzedAt":"2026-09-14T20:34:48.527Z","contentChangedAt":"2026-09-14T20:34:48.527Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}