Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Upgrade pypdf to 6.21.2 and map its moved size-limit checks (SKY-18829) (#9032)
Shuchang Zheng95e90db372a5
diff --git a/pyproject.toml b/pyproject.tomlindex fc96aaae3..1a9310b24 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -55,7 +55,7 @@ local = ["pyotp>=2.9.0,<3","json5>=0.15.0,<1","json-repair>=0.63.2,<0.64",- "pypdf>=6.19.0,<7",+ "pypdf>=6.21.1,<7","pdfplumber>=0.11.10,<0.12","beautifulsoup4>=4.14.3,<5","psutil>=7.0.0",@@ -132,7 +132,7 @@ server = ["asyncpg>=0.30.0,<0.32","json5>=0.15.0,<1","json-repair>=0.63.2,<0.64",- "pypdf>=6.19.0,<7",+ "pypdf>=6.21.1,<7","pdfplumber>=0.11.10,<0.12","beautifulsoup4>=4.14.3,<5",# <3.4: 3.4.3 enables HostOriginGuardMiddleware by default (421 on public hosts, SKY-12003).diff --git a/skyvern/forge/sdk/utils/pdf_parser.py b/skyvern/forge/sdk/utils/pdf_parser.pyindex 3f513302d..41e7bde81 100644--- a/skyvern/forge/sdk/utils/pdf_parser.py+++ b/skyvern/forge/sdk/utils/pdf_parser.py@@ -72,9 +72,10 @@ _MIN_ISOLATED_GLYPH_SHARE = 0.6# shares would be measuring the wrong thing._MIN_ASCII_LETTER_SHARE = 0.5# pypdf raises one LimitReachedError class for every limit, sometimes re-raised as PdfReadError, so only the raising-# frame tells a size cap from a structural limit pdfminer reads safely. Any limit in the filter modules is a size cap-# unless carved out below, so one a later pypdf adds fails closed; the frames after the carve-outs are the other caps-# pdfminer lacks: a content array, a ToUnicode range, CID widths and an eager page tree.+# frame (as of pypdf 6.21, the floor in pyproject.toml) tells a size cap from a structural limit pdfminer reads safely.+# Any limit in the filter modules is a size cap unless carved out below, so one a later pypdf adds fails closed; the+# frames after the carve-outs are the other caps pdfminer lacks: a content array, element and token counts, a ToUnicode+# range, CID widths and an eager page tree._PYPDF_DECOMPRESSION_LIMIT_MODULES = frozenset({"pypdf.filters", "pypdf._codecs._codecs"})# A predictor row length pdfminer never allocates, and JBIG2, which pdfminer passes through undecoded._PYPDF_STRUCTURAL_FILTER_FRAMES = frozenset(@@ -83,10 +84,13 @@ _PYPDF_STRUCTURAL_FILTER_FRAMES = frozenset(_PYPDF_SIZE_LIMIT_FRAMES = frozenset({("pypdf.generic._data_structures", "ContentStream.__init__"),+ ("pypdf.generic._data_structures", "ContentStream._check_limits"),+ ("pypdf.generic._data_structures", "ArrayObject._check_limits"),("pypdf.generic._data_structures", "DictionaryObject.read_from_stream"),+ ("pypdf.generic._data_structures", "DictionaryObject._read_stream_data"),("pypdf.generic._data_structures", "DictionaryObject._read_unsized_from_stream"),("pypdf._cmap", "_check_mapping_size"),- ("pypdf._doc_common", "PdfDocCommon._flatten_page_tree_node"),+ ("pypdf._doc_common", "PdfDocCommon._pop_next_page_tree_kid"),})# These frames also enforce structural limits (token lengths, simple-font widths), so the caller tells them apart.@@ -98,15 +102,15 @@ _PYPDF_SIZE_LIMIT_CALLS = frozenset(),(("pypdf._utils", "read_until_regex"),- ("pypdf.generic._data_structures", "DictionaryObject.read_from_stream"),+ ("pypdf.generic._data_structures", "DictionaryObject._read_stream_data"),),(- ("pypdf._font", "Font.__check_entry_count"),- ("pypdf._font", "Font._collect_cid_character_widths"),+ ("pypdf.generic._font", "Font.__check_entry_count"),+ ("pypdf.generic._font", "Font._collect_cid_character_widths"),),})-_PYPDF_CID_WIDTH_RANGE_FRAME = ("pypdf._font", "Font.__check_range_length")+_PYPDF_CID_WIDTH_RANGE_FRAME = ("pypdf.generic._font", "Font.__check_range_length")_PYPDF_PREDICTOR_PARAMETERS_FRAME = ("pypdf.filters", "FlateDecode._get_parameters")diff --git a/tests/unit/workflow/test_file_parser_block.py b/tests/unit/workflow/test_file_parser_block.pyindex 3336e44e5..2b4df594d 100644--- a/tests/unit/workflow/test_file_parser_block.py+++ b/tests/unit/workflow/test_file_parser_block.py@@ -1435,6 +1435,9 @@ class TestPypdfLimitFallback:{"content_length": 5}, {"maximum_declared_stream_length": 100}, id="stream_length_understated"),pytest.param({}, {"page_tree_maximum_entries": 0}, id="page_tree_entries"),+ pytest.param({}, {"array_maximum_element_count": 0}, id="array_elements"),+ pytest.param({}, {"dictionary_maximum_element_count": 0}, id="dictionary_entries"),+ pytest.param({}, {"stream_parsing_work_maximum_count": 0}, id="content_stream_tokens"),pytest.param({"cid_widths": b"[0 65535 500 65536 131071 500]"}, {}, id="cid_width_entries"),pytest.param({"gzip_content": True}, {"zlib_maximum_output_length": 64}, id="flate_recovery_output"),pytest.param(diff --git a/uv.lock b/uv.lockindex 64bafa57a..765d54969 100644--- a/uv.lock+++ b/uv.lock@@ -5827,11 +5827,11 @@ wheels = [[[package]]name = "pypdf"-version = "6.19.0"+version = "6.21.2"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/1f/ac/63d71aaedb59acbcdef491e6ca6469165e3771c9c74358204818fd9bc5a6/pypdf-6.19.0.tar.gz", hash = "sha256:bbc43aca292369ccc6cbc8a921991ecf2538a3587ab5a116eff06c321d647155", size = 7033266, upload-time = "2026-09-16T09:32:05.946Z" }+sdist = { url = "https://files.pythonhosted.org/packages/06/28/081f1cbcca7042441dafc8de00f48ba60853f89e5bff92c5f26477346d81/pypdf-6.21.2.tar.gz", hash = "sha256:0a3e1c5c886a1be03646c16a04827cc166c2a0575c971b26a4bf89686551c2d4", size = 7144571, upload-time = "2026-10-21T16:44:55.272Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/3c/2c/c43c03eaf630435f023f1dc61ec4a4a78951ad5530a62c71cc89bde307b7/pypdf-6.19.0-py3-none-any.whl", hash = "sha256:7e5d6e730e7dae87d560a2cee218b852f6498c8be61966f3cd02ead971e48d14", size = 395480, upload-time = "2026-09-16T09:32:04.087Z" },+ { url = "https://files.pythonhosted.org/packages/1b/4d/c9d2d67f204eff463237a1a8f5e25a6923b7b1043982b91fcaf104c8ef60/pypdf-6.21.2-py3-none-any.whl", hash = "sha256:1d44d1a3a200f25062adff0085b02040e4646431ac2ccac22e42679e91466084", size = 407766, upload-time = "2026-10-21T16:44:53.626Z" },][[package]]@@ -7136,8 +7136,8 @@ requires-dist = [{ name = "pyjwt", extras = ["crypto"], marker = "extra == 'server'", specifier = ">=2.15.1,<3" },{ name = "pyotp", marker = "extra == 'local'", specifier = ">=2.9.0,<3" },{ name = "pyotp", marker = "extra == 'server'", specifier = ">=2.9.0,<3" },- { name = "pypdf", marker = "extra == 'local'", specifier = ">=6.19.0,<7" },- { name = "pypdf", marker = "extra == 'server'", specifier = ">=6.19.0,<7" },+ { name = "pypdf", marker = "extra == 'local'", specifier = ">=6.21.1,<7" },+ { name = "pypdf", marker = "extra == 'server'", specifier = ">=6.21.1,<7" },{ name = "python-calamine", marker = "extra == 'local'", specifier = ">=0.8.2" },{ name = "python-calamine", marker = "extra == 'server'", specifier = ">=0.8.2" },{ name = "python-docx", marker = "extra == 'local'", specifier = ">=1.1.0" },