Add sglang sglang runtime path audit - #12
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new Python script, tools/maca_runtime_path_audit.py, designed to audit MACA-related environment path variables for duplicate or non-existent entries. Feedback on the implementation suggests fully normalizing paths (resolving relative paths and expanding user directories) to ensure robust duplicate detection, avoiding redundant existence checks for duplicate paths, and replacing the assert statement in the self-test with an explicit conditional check to prevent it from being optimized away in production environments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| normalized = str(Path(raw)) | ||
| if normalized in seen: | ||
| findings.append({"env": name, "path": raw, "severity": "warning", "message": "duplicate path entry"}) | ||
| seen.add(normalized) | ||
| if not Path(raw).exists(): | ||
| findings.append({"env": name, "path": raw, "severity": "info", "message": "path does not exist in this container"}) |
There was a problem hiding this comment.
Using str(Path(raw)) does not resolve relative paths to absolute paths, nor does it expand user directories (e.g., ~). This can cause duplicate detection to fail if the same path is specified in different formats (e.g., relative vs. absolute, or with/without ~). Normalizing paths using os.path.abspath(os.path.expanduser(raw)) ensures robust duplicate detection.\n\nAdditionally, checking path existence for duplicate entries results in redundant "path does not exist" findings for the same path. We should only perform the existence check for unique paths.
normalized = os.path.abspath(os.path.expanduser(raw))\n if normalized in seen:\n findings.append({\"env\": name, \"path\": raw, \"severity\": \"warning\", \"message\": \"duplicate path entry\"})\n else:\n seen.add(normalized)\n if not Path(raw).exists():\n findings.append({\"env\": name, \"path\": raw, \"severity\": \"info\", \"message\": \"path does not exist in this container\"})References
- Paths should be fully normalized (absolute and user-expanded) before duplicate checking to avoid missing duplicates represented in different formats.
| assert data["finding_count"] >= 2 | ||
| print(json.dumps({"ok": True, "finding_count": data["finding_count"]}, ensure_ascii=False)) |
There was a problem hiding this comment.
Using assert statements for validation or control flow is discouraged in production-bound scripts because assertions are removed when Python is run with optimization flags (e.g., python -O). If this script is executed with optimization enabled, the self-test will silently pass even if no findings are detected. It is safer to use an explicit conditional check and raise an exception.
if data[\"finding_count\"] < 2:\n raise RuntimeError(f\"Self-test failed: expected at least 2 findings, got {data['finding_count']}\")\n print(json.dumps({\"ok\": True, \"finding_count\": data[\"finding_count\"]}, ensure_ascii=False))References
- Do not use assert statements for runtime validation or self-tests in production-bound code, as they can be compiled away with optimization flags.
- Add SGLang MACA runtime path audit - Normalize MACA runtime path audit entries
Summary
Validation
Review notes