{"record":{"id":"cc067169b3ff75ba","repo":"vllm-project/vllm","slug":"unsupported-file-type-file-path","errorCode":null,"errorMessage":"Unsupported file type: {file_path}","messagePattern":"Unsupported file type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"tools/pre_commit/check_spdx_header.py","lineNumber":43,"sourceCode":"    MISSING_BOTH = \"missing_both\"  # Completely missing\n\n\nLICENSE_TEXT = \"SPDX-License-Identifier: Apache-2.0\"\nCOPYRIGHT_TEXT = \"SPDX-FileCopyrightText: Copyright contributors to the vLLM project\"\nFILE_STYLES = {\n    \".py\": HeaderStyle(\"#\", preserve_shebang=True),\n    \".rs\": HeaderStyle(\"//\"),\n    \".proto\": HeaderStyle(\"//\"),\n}\n\n\ndef file_style(file_path):\n    \"\"\"Return the declared header style for a file.\"\"\"\n    suffix = Path(file_path).suffix\n    try:\n        return FILE_STYLES[suffix]\n    except KeyError:\n        raise ValueError(f\"Unsupported file type: {file_path}\") from None\n\n\ndef spdx_header(style):\n    \"\"\"Return the SPDX header for a file style.\"\"\"\n    license_line = f\"{style.comment_prefix} {LICENSE_TEXT}\"\n    copyright_line = f\"{style.comment_prefix} {COPYRIGHT_TEXT}\"\n    return license_line, copyright_line\n\n\ndef header_insertion_index(style, lines):\n    \"\"\"Return the line index where a missing header should be inserted.\"\"\"\n    if style.preserve_shebang and lines and lines[0].startswith(\"#!\"):\n        return 1\n    return 0\n\n\ndef check_spdx_header_status(file_path):\n    \"\"\"Check SPDX header status of the file\"\"\"","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/tools/pre_commit/check_spdx_header.py#L25-L61","documentation":"The SPDX pre-commit hook only knows comment styles for .py, .rs, and .proto (FILE_STYLES map). When the hook is handed any other suffix, file_style() raises ValueError('Unsupported file type: ...'). This is a lint-time error in the hook itself, not a license problem in your file.","triggerScenarios":"The pre-commit hook's files filter matching a file with an unsupported extension (e.g. .cpp, .cu, .js, .md) — usually after the hook's file pattern was broadened or such a file was added under a directory the pattern covers.","commonSituations":"Contributing a new non-Python source file that the SPDX hook glob accidentally matches; editing .pre-commit-config.yaml to widen the hook's `files:`/`types:` filter.","solutions":["Narrow the hook configuration in .pre-commit-config.yaml so check_spdx_header only runs on file types it supports (files: '\\.(py|rs|proto)$').","If the new extension should carry SPDX headers, add a HeaderStyle entry to FILE_STYLES in tools/pre_commit/check_spdx_header.py (e.g. '.cpp': HeaderStyle('//')).","Exclude the specific file via the hook's `exclude:` pattern if it must not be checked."],"exampleFix":"# before (.pre-commit-config.yaml)\n- id: check-spdx-header\n  files: vllm/.*\n\n# after\n- id: check-spdx-header\n  files: \\.(py|rs|proto)$","handlingStrategy":"type-guard","validationCode":"from pathlib import Path\nSUPPORTED = {\".py\", \".rs\", \".proto\"}\nfiles = [f for f in staged_files if Path(f).suffix in SUPPORTED]  # only pass these to the hook","typeGuard":"from pathlib import Path\n\ndef is_spdx_supported(file_path: str) -> bool:\n    \"\"\"True when check_spdx_header.py can process this file.\"\"\"\n    return Path(file_path).suffix in {\".py\", \".rs\", \".proto\"}","tryCatchPattern":null,"preventionTips":["Keep the pre-commit hook's file filter in sync with FILE_STYLES when adding extensions.","Add a HeaderStyle entry for any new extension before committing files of that type.","Run `pre-commit run --all-files` locally before widening any hook's file patterns."],"tags":["pre-commit","lint","spdx","license","tooling"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}