What happened
Every request to POST /api/weblinks/upload fails with a generic {"code":500,"status":500,"message":"Internal server error"}, with or without filename_hint in the body.
opencontext/server/routes/documents.py::upload_weblink() calls
ok = component.submit_url(request.url, request.filename_hint)
but WebLinkCapture.submit_url() (opencontext/context_capture/web_link_capture.py) is declared as def submit_url(self, url: str), so the call raises
TypeError: WebLinkCapture.submit_url() takes 2 positional arguments but 3 were given
which the route's blanket except Exception turns into the 500 above. Both were added together in #289, and the endpoint has no caller in the frontend, so it never worked.
Reproduction
FastAPI TestClient against the real documents.py router + real ContextCaptureManager + real WebLinkCapture (only the server god-object stubbed):
payload={'url': 'https://example.com/', 'filename_hint': 'example'}
-> HTTP 500 {"code":500,"status":500,"message":"Internal server error"}
-> swallowed TypeError: WebLinkCapture.submit_url() takes 2 positional arguments but 3 were given
at opencontext/server/routes/documents.py, line 90, in upload_weblink
payload={'url': 'https://example.com/'}
-> HTTP 500 (same TypeError; the route passes filename_hint positionally even when it is None)
Expected behaviour
submit_url() accepts the filename_hint the route already sends and threads it through to convert_url_to_markdown() / convert_url_to_pdf(), which already take a filename_hint parameter — so the requested output filename is honoured instead of the endpoint crashing.
Note for whoever picks this up: after the signature fix, a stock install in the default markdown mode still answers 400 "Failed to queue URL" because the markdown path imports crawl4ai, which is not in pyproject.toml's dependencies (the log then says pip install crawl4ai); the pdf mode (playwright, declared) works end to end.
I have a small fix with unit tests ready and will open a PR referencing this issue.
(Found and verified with Claude Code, AI-assisted.)
What happened
Every request to
POST /api/weblinks/uploadfails with a generic{"code":500,"status":500,"message":"Internal server error"}, with or withoutfilename_hintin the body.opencontext/server/routes/documents.py::upload_weblink()callsbut
WebLinkCapture.submit_url()(opencontext/context_capture/web_link_capture.py) is declared asdef submit_url(self, url: str), so the call raiseswhich the route's blanket
except Exceptionturns into the 500 above. Both were added together in #289, and the endpoint has no caller in the frontend, so it never worked.Reproduction
FastAPI
TestClientagainst the realdocuments.pyrouter + realContextCaptureManager+ realWebLinkCapture(only the server god-object stubbed):Expected behaviour
submit_url()accepts thefilename_hintthe route already sends and threads it through toconvert_url_to_markdown()/convert_url_to_pdf(), which already take afilename_hintparameter — so the requested output filename is honoured instead of the endpoint crashing.Note for whoever picks this up: after the signature fix, a stock install in the default
markdownmode still answers400 "Failed to queue URL"because the markdown path importscrawl4ai, which is not inpyproject.toml's dependencies (the log then sayspip install crawl4ai); thepdfmode (playwright, declared) works end to end.I have a small fix with unit tests ready and will open a PR referencing this issue.
(Found and verified with Claude Code, AI-assisted.)