Skip to content

feat(ai): fetch page text with the Crawl4AI service - #3943

Merged
dan-petty merged 3 commits into
mainfrom
feat/3887-crawl4ai-page-text
Nov 7, 2026
Merged

dan-petty merged 3 commits into
mainfrom
feat/3887-crawl4ai-page-text

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Add fetch_page_text, a typed client for POST /md of the Crawl4AI service. It checks the page URL (http or https, no private, loopback or metadata host), caps the reply in bytes and the text in characters, counts each fetch in devops_cli_crawl4ai_fetches_total, and logs no token or page query. New setting crawl4ai.url and credential crawl4ai.api_token. No tool uses it yet.

Closes #3887

Change: openspec/changes/archive/2026-11-07-3887-crawl4ai-page-text/

@dan-petty dan-petty added type/feature Type feature: a new function scope/ai AI review pipeline, personas, prompts, LLM client, or RAG labels Nov 7, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Evidence for PR 3943 (issue 3887).

Premise. The reply shape of POST /md was read from deploy/docker/server.py at Crawl4AI v0.9.5: the handler get_markdown is at line 616, and it answers with url, filter, query, cache, markdown and success (lines 644 to 651). The fixture tests/fixtures/crawl4ai/md_response.json holds that shape. handle_markdown_request in api.py calls validate_url_destination and enforce_egress. entrypoint.sh binds loopback only when no CRAWL4AI_API_TOKEN is set (lines 27 to 33).

Page URL guard. The client uses is_loopback_or_private_host of devops_cli.core.validation. It holds is_non_public_ip and is_cloud_metadata_name, and it also refuses names that are not public DNS names, such as kubernetes.default.svc. No IP or regex check was written. A public name that resolves to a private address passes the client check; the service pins the address it dials. Issue 3894 tests that live.

Tests. tests/ai/test_page_text.py has 38 cases on the HTTP fake. They fail on the base, since the module does not exist there. They cover the bearer header and body, the cut at the cap, 15 refused page URLs with no request sent, the statuses 401, 403, 429, 500 and 504 with the counter label and no token or query in the log, a redirect that is not followed, no-answer cases, the byte cap, and the empty setting and token.

Checks that I ran.

  • Full uv run devops ci once (under the shared lock) on the rebased branch: 8 failures, all mine: the key lists of tests/security/test_config_declarations.py, the similar-key hints of tests/commands/test_config.py, the key count of tests/commands/test_config_audit_keys.py, a bandit B105 on a constant name, a __file__ read in the new test, and a private address in the spec text. I fixed each at its cause.
  • After the fixes: devops ci test on the 6 touched test files and tests/config (139 passed), devops ci --only test-tree (pass), devops ci --only security (pass), devops ci --only docs and --only openspec (pass), ruff and mypy (pass). I did not run the full gate a second time, because the shared lock queue was over an hour long. The checks of this pull request run it.
  • The full run took 7m 15s for tests, over the 5 minute budget: a known problem (issue 3593).
  • tests/docs/test_docs_source_argv_collector.py errors in a worktree under .data/agent/worktrees/ (host path reached without a fake: .../config.yaml). It fails the same way on origin/main in this worktree, so it is not from this change.

Known failures. The Runner Image and Service Image checks fail on CVE-2026-78661 until the Trivy ignore of issue 3881 (PR 3926) merges. That is not from this change. I will not mark the pull request ready while only those two checks fail.

Overlap. Issue 3882 plans the same credential crawl4ai.api_token and its cluster Secret rows. This change adds only the credential row that the client reads, with the alias CRAWL4AI_API_TOKEN. If 3882 merges first, a rebase takes its row and the same lines in tests/security/test_config_declarations.py.

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review November 7, 2026 06:04
Add fetch_page_text, a typed client for POST /md of the Crawl4AI service. It checks the page URL, caps the reply and the text, counts each fetch, and reads crawl4ai.url and the crawl4ai.api_token credential.
@dan-petty
dan-petty force-pushed the feat/3887-crawl4ai-page-text branch from 0c358a3 to 20c3aed Compare November 7, 2026 11:52
@dan-petty
dan-petty merged commit 038e71c into main Nov 7, 2026
24 checks passed
@dan-petty
dan-petty deleted the feat/3887-crawl4ai-page-text branch November 7, 2026 12:00
dan-petty-release Bot added a commit that referenced this pull request Nov 7, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.79.0](v0.78.0...v0.79.0)
(2026-11-07)


### Features

* **ai:** fetch page text with the Crawl4AI service
([#3943](#3943))
([038e71c](038e71c)),
closes [#3887](#3887)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Nov 7, 2026
Adds the Crawl4AI page-text service to the devops stack: Deployment,
Service and NetworkPolicies in k8s/devops/crawl4ai/, on the pinned
release 0.9.5. Only the roadmap-service pods may call it, and its egress
reaches public ports 80 and 443 only. A new bearer token restarts the
pod. A CI job reports vulnerabilities of the pinned image without
failing the pull request. The service answers the client of #3943 and
the token row of #3937. No Ingress or route names it.

Closes #3884

Change: `openspec/changes/archive/2026-11-07-3884-crawl4ai-manifests/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ai): fetch page text with the Crawl4AI service

1 participant