{"record":{"id":"b75b38cea2e84ff9","repo":"larksuite/cli","slug":"expected-type-name","errorCode":null,"errorMessage":"expected {type_name}","messagePattern":"expected (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/lark-slides/scripts/sxsd_validator.py","lineNumber":506,"sourceCode":"        if value not in {\"true\", \"false\", \"1\", \"0\"}:\n            raise ValueError(\"expected boolean\")\n        return value in {\"true\", \"1\"}\n    if type_name in {\"integer\", \"positiveInteger\", \"nonNegativeInteger\"}:\n        if re.fullmatch(r\"[+-]?\\d+\", value) is None:\n            raise ValueError(\"expected integer\")\n        number = Decimal(value)\n        if type_name == \"positiveInteger\" and number <= 0:\n            raise ArithmeticError(\"expected positive integer\")\n        if type_name == \"nonNegativeInteger\" and number < 0:\n            raise ArithmeticError(\"expected non-negative integer\")\n        return number\n    if type_name in {\"double\", \"decimal\"}:\n        lexical_value = value.strip(\" \\t\\n\\r\")\n        decimal_pattern = r\"[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)\"\n        double_pattern = decimal_pattern + r\"(?:[eE][+-]?[0-9]+)?\"\n        expected_pattern = double_pattern if type_name == \"double\" else decimal_pattern\n        if re.fullmatch(expected_pattern, lexical_value) is None:\n            raise ValueError(f\"expected {type_name}\")\n        try:\n            number = Decimal(lexical_value)\n        except InvalidOperation as error:\n            raise ValueError(f\"expected {type_name}\") from error\n        if not math.isfinite(float(number)):\n            raise ValueError(f\"expected finite {type_name}\")\n        return number\n    return value\n\n\ndef scalar_value_for_type(\n    type_name: str,\n    value: str,\n    model: SchemaModel,\n    resolving: set[str] | None = None,\n) -> Decimal | str | bool:\n    resolving = resolving or set()\n    if type_name in resolving:","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/skills/lark-slides/scripts/sxsd_validator.py#L488-L524","documentation":"This ValueError is raised by builtin_scalar_value when a value typed xsd:double or xsd:decimal fails the XSD lexical pattern for that type. decimal allows only plain decimal notation; double additionally allows scientific exponent notation. The message interpolates the offending type name.","triggerScenarios":"Calling scalar_value_for_type with type_name 'double' or 'decimal' and values like '1,5' (comma decimal separator), 'NaN', 'INF', '1e5' for decimal (exponent not allowed), '1.2.3', or whitespace-embedded numbers.","commonSituations":"Locale-formatting bugs exporting '1,5' instead of '1.5'; XML producers emitting INF/NaN for doubles where XSD forbids them; scientific notation used in decimal fields; empty or placeholder values.","solutions":["Rewrite the value using '.' as the decimal separator and no thousands separators.","For xsd:decimal, remove the exponent (convert '1.5e3' to '1500').","For special values use the appropriate type or sentinel allowed by the schema instead of INF/NaN.","Fix the serializer to use invariant culture / non-locale number formatting."],"exampleFix":"// before\n<scale factor=\"1,5e2\"/>  <!-- decimal with comma+exponent -->\n// after\n<scale factor=\"150\"/>","handlingStrategy":"validation","validationCode":"import re\ndouble_re = re.compile(r'[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?')\ndecimal_re = re.compile(r'[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)')\nassert decimal_re.fullmatch('1.5') is not None  # no commas, no exponent for decimal","typeGuard":"def is_xsd_number(text, allow_exponent=False):\n    import re\n    base = r'[+-]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)'\n    pat = base + (r'(?:[eE][+-]?[0-9]+)?' if allow_exponent else '')\n    return re.fullmatch(pat, text.strip()) is not None","tryCatchPattern":"try:\n    value = scalar_value_for_type('decimal', raw)\nexcept ValueError as e:\n    print(f'fix lexical form (use \"1.5\" style): {e}')","preventionTips":["Serialize numbers with invariant/POSIX locale (never comma decimal separators).","Avoid INF/NaN literals in XSD numeric fields.","Use exponent-free formatting for xsd:decimal values."],"tags":["python","xsd","number-format"],"backgroundTag":"xsd-numeric-lexical-format","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}