omi
omi copied to clipboard
[Bounty proposal] fix(web-tools): validate non-empty url, decode html entities, and support json-ld graph ($50 proposed)
Summary
In ackend/utils/retrieval/tools/web_tools.py:
- Invoking etch_url_tool(None) or with non-string/empty input triggers an unhandled AttributeError: 'NoneType' object has no attribute 'startswith' on line 299, instead of returning a user-friendly error.
- In _extract_meta_tags, titles and meta descriptions containing HTML entities (such as &, ', ") are left unescaped, leading to degraded readability and noisy downstream LLM context.
- In _extract_json_ld, Schema.org graphs formatted via top-level {"@graph": [...]} (standard across WordPress, Yoast, and major media sites) fail to unpack nested entities, leaving canonical titles, authors, and descriptions undetected.
- There is no unit test suite for web_tools.py.
Proposed Changes
- URL Validation & Sanitization: Sanitize and validate clean_url = str(url or '').strip() early in etch_url_tool. Return Error: URL cannot be empty. and Error: URL must start with http:// or https:// safely without crashing on None.
- HTML Entity Decoding: Unescape entities in extracted titles, meta descriptions, and structured data using Python's standard html.unescape.
- JSON-LD @graph Unpacking: Add support for unpacking entry['@graph'] in _extract_json_ld to extract structured metadata from modern CMS sites.
- Hermetic Unit Tests: Add ackend/tests/unit/test_web_tools.py testing URL validation, SSRF checks, HTML stripping, JSON-LD unpacking, HTTP status handling, and content-type filtering.
Bounty: $50 proposed.
PR created with hermetic unit tests: https://github.com/BasedHardware/omi/pull/23125
Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏