Add compose v5 compatibility, legacy-field warnings, UI error fixes - #2094
Conversation
614593c to
12d138b
Compare
|
Nice work on the legacy-compat warnings. One interaction seems worth a look. The pre-existing gate in if crawl_request.hooks and not HOOKS_ENABLED:
raise HTTPException(403, "Hooks are disabled. Set CRAWL4AI_HOOKS_ENABLED=true to enable.")
Since Smallest version, no status codes change: keep firing on presence, but branch the error detail on what is actually inside, e.g.: if crawl_request.hooks and not HOOKS_ENABLED:
if crawl_request.hooks.code:
raise HTTPException(
403,
"Inline hook code (hooks.code) was removed in 0.9.0 and cannot be "
"enabled; it was not executed. Use declarative hook actions instead "
"(GET /hooks/info), which are additionally disabled on this server "
"(CRAWL4AI_HOOKS_ENABLED).",
)
raise HTTPException(403, "Hooks are disabled. Set CRAWL4AI_HOOKS_ENABLED=true to enable.")Probably worth hoisting into a small helper, since the gate appears in both Related question: did you consider rejecting |
|
@SetagGnaw Good catch on the ordering. On a stock deployment ( I've adopted your suggested shape: keep firing on presence (the 403-when-disabled contract stays pinned by On your 400 vs. 200 + warning question: I considered rejecting
Thanks for the review! |
|
Nice work Soham — the #2091 diagnosis was thorough and these fixes are well-targeted. A few things to sort out before merge. Blocking1. The compose change silently disabled an existing security test. Also, 2. Issue item 2 is unaddressed, and it undercuts your own item-3 fix. While you're in that file: 3. 4. Should fix
Hooks response shape.
Playground. Two follow-ons: FastAPI 422s return Entrypoint message. The bind guard at Needs a call from @unclecodeIssue item 4 says "reject (or warn on)" Deferred / nits
If you'd rather keep this PR tight, narrow the "Fixes #2091" claim and open a follow-up for the rest — that works for me too. |
|
@ntohidi thanks for the thorough review. Everything is addressed in the follow-up commit except item 2, which I held back deliberately; reasoning below. Blocking 1 — done, both halves. Blocking 2 — not addressed, on purpose; I'd like your read before touching it. Both one-liners have failure modes worse than the current annoyance:
Given those trade-offs, I'd treat item 2 as its own change with its own decision (e.g. whether a Compose ≥2.24 floor is acceptable) rather than fold it in here. If you're comfortable accepting the trade-offs, I can pick it up in a follow-up PR. Blocking 3 — done. Blocking 4 — done. output_path — done as suggested, with one heads-up: declaring the field required relaxing Hooks seed, /monitor test, playground — all done as suggested. The playground error paths are covered by extracted-function assertions (422 array → Entrypoint message — adjusted, with a finding you'll want to know: |
|
Thanks for this — I went through all seven points in #2091 and verified each one against 1. Please rebase — there's one conflict
Cause: commit # check if all of the results are not successful
if all(not result["success"] for result in results["results"]):
raise HTTPException(500, f"Crawl request failed: {results['results'][0]['error_message']}")Your branch predates that commit, so it still carries them, and the new legacy-hooks block lands right next to them. Resolution: keep your hooks block, drop those three lines. That's the whole conflict — nothing else in the PR clashes. 2. Point 2 of the issue isn't covered yetThe compose change here only moves the PID cap. Point 2 of #2091 is still open in
Could you add both in the same push? env_file:
- path: .llm.env
required: false
environment:
- CRAWL4AI_API_TOKEN=${CRAWL4AI_API_TOKEN:-}While you're in that file: Not blockingPoint 7's Everything else — the Compose v5 PID fix, the entrypoint warning, the |
…und error handling - docker-compose.yml: move the PID cap to deploy.resources.limits.pids (Compose v5 rejects pids_limit alongside a limits block; same behavior on v2.x). - entrypoint.sh: explain the loopback-only bind when no CRAWL4AI_API_TOKEN is set and how to fix it. - server.py: warn when the removed output_path (screenshot/pdf) or legacy hooks.code is sent - fields are ignored, never executed; hooks status reads "ignored" and /crawl/stream sends X-Hooks-Warning. Make "/" public so the /playground redirect works; data routes stay gated. - schemas.py: capture legacy hooks.code so it can be reported (never run). - playground: check response.ok on the streaming branch, surface server error details, hint at the token bar on 401. - tests: add deploy/docker/tests/test_legacy_compat.py (13 tests).
Per review: enabling CRAWL4AI_HOOKS_ENABLED cannot run inline hook code (removed in 0.9.0), so code-carrying payloads now get a removal message instead of the misleading generic hint.
…ompat tests - output_path back as a deprecated schema field (visible in OpenAPI); hooks.code widened to Optional[Any] - pids test parses compose YAML instead of grepping raw text - security pins replaced with a behavioral no-file-written test - playground: readable 422 errors, non-JSON error bodies handled - entrypoint: JWT flag tied to security.jwt_enabled in config.yml
…v optional Pass the token from the shell (or project .env) via environment, make .llm.env optional with required: false, drop the obsolete version key, and align entrypoint hint and docs
2795378 to
e07ac4f
Compare
|
Done, both the points have been resolved. Point 2 - added your snippet, plus One thing I hit while testing: Tested live against an image from this branch: export → reachable with auth working, Left the |
Summary
Companion to the self-hosting docs update; all changes verified against a built 0.9.2 image.
docker-compose.yml:
compose down. Identical behavior on Compose v2.x.entrypoint.sh:
server.py / schemas.py:
static/playground/index.html:
detailmessage instead of a generic "Request failed", and 401s hint at the token bar (distinguishing "no token set" from "token rejected").tests:
Fixes #2091
List of files changed and why
deploy/docker/entrypoint.shdeploy/docker/schemas.pydocker/server.pydocker/static/playground/index.htmldeploy/docker/tests/test_legacy_compat.pydocker-compose.ymlHow Has This Been Tested?
Ran old tests and also created a new test file to test the changes. Manually verified as well.
Checklist: