fix(backend/copilot): catch openpyxl.InvalidFileException in bare ref parsing

InvalidFileException extends Exception directly (not ValueError/OSError),
so it wasn't caught by the existing exception tuple. Corrupt .xlsx files
would crash instead of raising FileRefExpansionError.
This commit is contained in:
Zamil Majdy
2026-03-14 06:56:26 +07:00
parent 81c51f91f3
commit 5873dc81fe

View File

@@ -43,6 +43,7 @@ from dataclasses import dataclass
from typing import Any
import yaml
from openpyxl.utils.exceptions import InvalidFileException as OpenpyxlInvalidFile
from backend.copilot.context import (
get_current_sandbox,
@@ -469,6 +470,7 @@ async def _expand_bare_ref(
KeyError,
TypeError,
zipfile.BadZipFile,
OpenpyxlInvalidFile,
) as exc:
raise FileRefExpansionError(f"Failed to parse {fmt} file: {exc}") from exc
# Normalize bytes fallback to str so tools never