Skip to content

Harden HTTP validation, error handling, and template management - #266

Closed
thomas9120 wants to merge 10 commits into
mainfrom
beta
Closed

Harden HTTP validation, error handling, and template management#266
thomas9120 wants to merge 10 commits into
mainfrom
beta

Conversation

@thomas9120

Copy link
Copy Markdown
Owner

Significant bug fixes, first pass with more to come. Prepping for v2.0.0.

Suppress console window for llama.cpp runtime on Windows
Validate incoming HTTP bodies and origins: read_body now returns None for valid JSON that is not an object and get_request_content_length rejects Transfer-Encoding (501). Handlers return a 400 for malformed/invalid JSON. Harden get_request_host_origin against malformed Host ports (avoid ValueError). Use build_http_origin when composing URLs so IPv6 hosts are bracketed across backend services, tunnel args, app messages and the API tab UI. Also read preset files as UTF-8 and add/adjust unit tests and docs to cover these behaviors.
Print real exceptions to stderr and sanitize user-facing error text across several routes and services (hf_download, web_search, tunnel, status, file_picker). Move file-picker initial_dir.mkdir into the protected block so directory creation failures are handled and logged. Preserve existing config keys (e.g. external_chat_target) when rewriting config.json by loading, updating, and saving instead of overwriting. Update unit tests and docs to assert stderr logging and the preserved config behavior. Files touched: backend/routes/*, backend/services/*, tests/backend/*, and docs/code-review-2026-07-29.md.
Set Jinja templates default to enabled and add --no-jinja false_flag; remove unsupported apply_diff tool option. Enforce chat-template XOR so a custom template file wins over a builtin name and add UI handling to display unknown builtin template names in dropdowns. Use Number/Number.isFinite for numeric parsing (preserve exponent notation). Prevent stray empty assistant bubble on empty chat responses. Add console.debug to previously silent catches. Update frontend unit/e2e tests and sync AGENTS/docs to reflect fetchJson behavior and the other fixes.
Add two new docs: a full-repo code-review (code-review-swarm-2026-07-29.md) and its independent verification (code-review-swarm-2026-07-29-verification.md). Update tests/backend/test_services.py to supply an io.BytesIO as the HTTPError body and assert the body is closed after probing — preventing an open stream leak and aligning the test with expected cleanup behavior.
Multiple hardening fixes across backend and frontend:
- backend: sanitize handler exceptions and track Response.started; bench route serializes wikitext2 extraction with .part file and size checks; hf download verifies Content-Length; send_input no longer holds process_lock, writes via bounded thread.
- frontend: avoid clobbering focused flag/quick-launch inputs, pass force on wholesale flag applies, await stream aborts in chat, tolerate transient benchmark output failures.
- Add .gitattributes eol pins and tests verifying the changes.
@thomas9120 thomas9120 closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant