{"record":{"id":"e4bc54068b9bbfba","repo":"vllm-project/vllm","slug":"line-node-lineno-message","errorCode":null,"errorMessage":"❌ line({node.lineno}): {message}","messagePattern":"❌ line\\((.+?)\\): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"tools/pre_commit/validate_config.py","lineNumber":150,"sourceCode":"\n\ndef validate_file(file_path: str):\n    try:\n        print(f\"Validating {file_path} config dataclasses \", end=\"\")\n        with open(file_path, encoding=\"utf-8\") as f:\n            source = f.read()\n\n        tree = ast.parse(source, filename=file_path)\n        validate_ast(tree)\n    except ValueError as e:\n        print(e)\n        raise SystemExit(1) from e\n    else:\n        print(\"✅\")\n\n\ndef fail(message: str, node: ast.stmt):\n    raise ValueError(f\"❌ line({node.lineno}): {message}\")\n\n\ndef main():\n    for filename in sys.argv[1:]:\n        # Only run for Python files in vllm/ or tests/\n        if not re.match(r\"^(vllm|tests)/.*\\.py$\", filename):\n            continue\n        # Only run if the file contains @config\n        with open(filename, encoding=\"utf-8\") as f:\n            if \"@config\" in f.read():\n                validate_file(filename)\n\n\nif __name__ == \"__main__\":\n    main()\n","sourceCodeStart":132,"sourceCodeEnd":166,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/tools/pre_commit/validate_config.py#L132-L166","documentation":"tools/pre_commit/validate_config.py walks the AST of files under vllm/ and tests/ that use the @config decorator and enforces rules on config classes (e.g. disallowed statements in decorated classes). fail() raises ValueError with the offending line number; main() prints it and exits 1, failing the pre-commit run.","triggerScenarios":"Adding or editing a class decorated with @config in vllm/ or tests/ in a way the validator forbids — e.g. statements inside the config class body that the AST validator rejects — then running pre-commit (validate_config hook) on that file.","commonSituations":"Contributing a new config dataclass to vllm/config.py and writing logic (assignments, imports, function defs) the validator prohibits; refactoring an existing @config class so it trips a rule that previously passed.","solutions":["Open the file at the reported line number and fix the flagged construct (move logic out of the @config class body, keep only field/schema definitions).","Run `pre-commit run validate-config --files <yourfile>` locally to iterate quickly before pushing.","Mirror the style of existing @config classes in vllm/config.py (declarative fields only)."],"exampleFix":"# before (vllm/my_config.py)\n@config\nclass MyConfig:\n    total = a + b  # ❌ line(8): dynamic statement in @config class\n\n# after\n@config\nclass MyConfig:\n    a: int = 1\n    b: int = 2","handlingStrategy":"try-catch","validationCode":"# Fast local gate before committing @config changes\nimport subprocess, sys\nrc = subprocess.run([\"python\", \"tools/pre_commit/validate_config.py\", \"vllm/config.py\"]).returncode\nif rc != 0:\n    raise SystemExit(\"Fix @config violations before committing\")","typeGuard":null,"tryCatchPattern":"try:\n    validate_file(path)  # tools/pre_commit/validate_config.py\nexcept ValueError as e:\n    print(e)  # message carries the offending line number\n    raise SystemExit(1)","preventionTips":["Run the validate_config pre-commit hook locally before every push touching @config classes.","Keep @config class bodies declarative; put logic elsewhere.","Copy the structure of existing config classes in vllm/config.py."],"tags":["pre-commit","lint","config","ast","tooling"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}