{"record":{"id":"619f2f7bde4623a6","repo":"langflow-ai/langflow","slug":"class-name-class-name-r-is-a-windows-reserved-de","errorCode":null,"errorMessage":"class_name {class_name!r} is a Windows-reserved device name","messagePattern":"class_name (.+?) is a Windows-reserved device name","errorType":"validation","errorClass":"UserComponentError","httpStatus":null,"severity":"error","filePath":"src/backend/base/langflow/agentic/services/user_components.py","lineNumber":233,"sourceCode":"    # has to reason about pathological inputs.\n    if len(class_name) > MAX_CLASS_NAME_LENGTH:\n        msg = f\"class_name length {len(class_name)} exceeds max {MAX_CLASS_NAME_LENGTH} (Windows MAX_PATH safeguard)\"\n        raise UserComponentError(msg)\n    # Filesystem-portability guard (rejects NUL, Windows-forbidden punct,\n    # path separators, dotdot, control chars, trailing dot/space, etc.).\n    if err := _check_windows_portability(class_name):\n        raise UserComponentError(err)\n    # Reject `.`, `..`, leading dots, leading underscores, dunders, and\n    # anything that isn't a valid CamelCase identifier.\n    if not _CLASS_NAME_RE.fullmatch(class_name):\n        msg = (\n            f\"class_name must be a CamelCase identifier \"\n            f\"(letters/digits/underscores, leading uppercase). Got: {class_name!r}\"\n        )\n        raise UserComponentError(msg)\n    if class_name.upper() in _WINDOWS_RESERVED_DEVICES:\n        msg = f\"class_name {class_name!r} is a Windows-reserved device name\"\n        raise UserComponentError(msg)\n\n\ndef _validate_code(code: str) -> None:\n    if not code or not code.strip():\n        msg = \"code must be a non-empty string\"\n        raise UserComponentError(msg)\n    encoded_size = len(code.encode(\"utf-8\"))\n    if encoded_size > MAX_COMPONENT_SOURCE_BYTES:\n        msg = f\"code size {encoded_size} bytes exceeds limit of {MAX_COMPONENT_SOURCE_BYTES} bytes\"\n        raise UserComponentError(msg)\n\n\ndef _resolve_components_dir(*, user_id: str | None) -> Path:\n    \"\"\"Resolve and create ``<sandbox>/.components/`` for the given user.\n\n    Reuses the FS tool's authoritative sandbox resolver so the hash\n    function, pepper handling, AUTO_LOGIN dispatch, and no-user refusal\n    stay in one place. The reserved-segment guard does NOT apply here —","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/agentic/services/user_components.py#L215-L251","documentation":"Raised when the (uppercased) class name matches a Windows reserved device name: CON, PRN, AUX, NUL, COM1-COM9, LPT1-LPT9. These are valid Python identifiers and pass the CamelCase regex, but Windows refuses to create files with those stems, so the registry guard rejects them explicitly to keep sandboxes cross-platform portable.","triggerScenarios":"register_user_component with class_name 'Con', 'NUL', 'Aux', 'Com1', 'LPT1' etc. — the check is case-insensitive (class_name.upper()).","commonSituations":"Short generated names colliding with DOS device names ('Aux' is a realistic generator output); deliberate edge-case testing; names like 'Con' from truncating 'Connection'.","solutions":["Rename the class to something that is not a DOS device name, e.g. 'AuxHandler' instead of 'Aux'.","Lengthen or prefix generated names so they can never equal the 20 reserved tokens."],"exampleFix":"# before\nregister_user_component(user_id=uid, class_name=\"Aux\", code=src)\n\n# after\nregister_user_component(user_id=uid, class_name=\"AuxiliaryHelper\", code=src)","handlingStrategy":"validation","validationCode":"WINDOWS_RESERVED = {\"CON\",\"PRN\",\"AUX\",\"NUL\", *(f\"COM{i}\" for i in range(1,10)), *(f\"LPT{i}\" for i in range(1,10))}\n\ndef not_windows_device(name: str) -> bool:\n    return name.upper() not in WINDOWS_RESERVED","typeGuard":"def is_safe_file_stem(name: str) -> TypeGuard[str]:\n    return bool(re.fullmatch(r\"[A-Z][A-Za-z0-9_]*\", name)) and name.upper() not in WINDOWS_RESERVED","tryCatchPattern":"try:\n    register_user_component(user_id=uid, class_name=name, code=src)\nexcept UserComponentError as e:\n    if \"Windows-reserved\" in str(e):\n        name += \"Component\"  # CON -> CONComponent\n        register_user_component(user_id=uid, class_name=name, code=src)","preventionTips":["Avoid 3-letter device-like names (CON, AUX, NUL, PRN, COMn, LPTn) when naming generated classes.","Prefer descriptive multi-word class names; they cannot collide with reserved devices."],"tags":["validation","windows","reserved-names","user-components"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}