-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
fix(docker): add pypdf and honor stream scraping strategy #2130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ PyJWT==2.10.1 | |
| mcp>=1.18.0 | ||
| websockets>=15.0.1 | ||
| httpx[http2]>=0.27.2 | ||
| pypdf | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import ast | ||
| from pathlib import Path | ||
|
|
||
| ROOT = Path(__file__).resolve().parent.parent | ||
|
|
||
|
|
||
| def test_default_docker_dependencies_include_pypdf(): | ||
| requirements = ( | ||
| (ROOT / "deploy" / "docker" / "requirements.txt").read_text().splitlines() | ||
| ) | ||
|
|
||
| assert "pypdf" in requirements | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exact-line match breaks as soon as the requirement gets a version spec (e.g. from packaging.requirements import Requirement, InvalidRequirement
def test_default_docker_dependencies_include_pypdf():
lines = (ROOT / "deploy" / "docker" / "requirements.txt").read_text().splitlines()
names = set()
for line in lines:
line = line.strip()
if not line or line.startswith(("#", "-")):
continue
try:
names.add(Requirement(line).name)
except InvalidRequirement:
continue # pip-specific syntax (inline comments, paths, etc.)
assert "pypdf" in names
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in 10130de. The regression now parses each valid requirement with |
||
|
|
||
|
|
||
| def test_stream_handler_preserves_requested_scraping_strategy(): | ||
| tree = ast.parse((ROOT / "deploy" / "docker" / "api.py").read_text()) | ||
| handler = next( | ||
| node | ||
| for node in tree.body | ||
| if isinstance(node, ast.AsyncFunctionDef) | ||
| and node.name == "handle_stream_crawl_request" | ||
| ) | ||
| assigned_attributes = { | ||
| target.attr | ||
| for node in ast.walk(handler) | ||
| if isinstance(node, ast.Assign) | ||
| for target in node.targets | ||
| if isinstance(target, ast.Attribute) | ||
| } | ||
|
|
||
| assert "scraping_strategy" not in assigned_attributes | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This asserts on the shape of the source rather than the behavior, which makes it both bypassable and over-strict — I verified both directions locally:
A behavioral test would guard the actual contract. For example: load the issue's payload through
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced the AST assertion in 10130de with an async behavioral test. It invokes the real |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to
pypdf>=6.0.0in 10130de, matching the library's root requirement.