{"record":{"id":"d99f0bd325af6693","repo":"microsoft/autogen","slug":"file-path-does-not-exist","errorCode":null,"errorMessage":"File {path} does not exist.","messagePattern":"File (.+?) does not exist\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"python/packages/agbench/src/agbench/linter/cli.py","lineNumber":39,"sourceCode":"def load_log_file(path: str, prepend_numbers: bool = False) -> Document:\n    with open(path, \"r\") as f:\n        lines = f.readlines()\n    if prepend_numbers:\n        lines = prepend_line_numbers(lines)\n\n    text = \"\".join(lines)\n    return Document(text=text, name=os.path.abspath(path))\n\n\ndef code_log(path: str) -> Optional[CodedDocument]:\n    coder = OAIQualitativeCoder()\n\n    if os.path.isfile(path):\n        doc = load_log_file(path, prepend_numbers=True)\n        coded_doc = coder.code_document(doc)\n        return coded_doc\n    else:\n        raise FileNotFoundError(f\"File {path} does not exist.\")\n\n\ndef print_coded_results(input_path: str, coded_doc: CodedDocument) -> None:\n    num_errors: int = 0\n    # define map from severity to ANSI color\n    severity_color_map = {2: \"\\033[31m\", 1: \"\\033[33m\", 0: \"\\033[32m\"}\n\n    # sort the codes by severity with the most severe first\n    sorted_codes = sorted(coded_doc.codes, key=lambda x: x.severity, reverse=True)\n\n    for code in sorted_codes:\n        # select color based on severity, default to white if missing\n        color = severity_color_map.get(code.severity, \"\\033[37m\")\n        print(f\"{color}[{code.severity}]: {code.name}\\033[0m: {code.definition}\")\n        for example in code.examples:\n            print(f\"\\033[1m{input_path}\\033[0m:{example.line}\" f\":{example.line_end}\\t{example.reason}\")\n            num_errors += 1\n    print(\"\\n\")","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/agbench/src/agbench/linter/cli.py#L21-L57","documentation":"FileNotFoundError raised by agbench's code_log CLI helper when the path passed to the 'code' command does not point to an existing file. The helper branches on os.path.isfile(path) and explicitly raises with the offending path when the check fails, before any LLM coding happens.","triggerScenarios":"Running the agbench linter code command with a misspelled path, a directory instead of a file, a relative path resolved from the wrong working directory, or a file that was moved/deleted.","commonSituations":"Shell tab-completion typos; running the CLI from a different cwd so relative paths break; passing a glob that the shell did not expand; referencing benchmark output files that a previous step failed to write.","solutions":["Check the path exists and is a file before invoking the command: os.path.isfile(path) / test -f.","Use an absolute path or run the CLI from the directory containing the log file.","If you expected the file to be generated by an earlier agbench step, verify that step succeeded first."],"exampleFix":"# before\nagbench lint code runs/results/missing.jsonl\n\n# after\nls runs/results/ # confirm the filename\nagbench lint code \"$(pwd)/runs/results/actual_name.jsonl\"","handlingStrategy":"validation","validationCode":"import os, sys\npath = sys.argv[1]\nif not os.path.isfile(path):\n    sys.exit(f\"error: no such file: {path}\")\n# safe to call the code command now","typeGuard":"from pathlib import Path\n\ndef is_codable_log(p: str) -> bool:\n    return Path(p).is_file() and Path(p).stat().st_size > 0","tryCatchPattern":"try:\n    coded = code_log(path)\nexcept FileNotFoundError as e:\n    print(f\"Input not found: {e}. Check the path and cwd.\")\n    raise SystemExit(2)","preventionTips":["Pass absolute paths to the CLI or verify cwd first.","Check the file exists and is non-empty before invoking the command.","Confirm upstream benchmark steps produced the log you mean to lint."],"tags":["python","cli","filesystem","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}