Skip to content

fix(api): support emoji and punycode domains in analysis tasks#150

Merged
vvatelot merged 2 commits into
mainfrom
fix/punycode-emoji-domains
Jul 15, 2026
Merged

fix(api): support emoji and punycode domains in analysis tasks#150
vvatelot merged 2 commits into
mainfrom
fix/punycode-emoji-domains

Conversation

@vvatelot

@vvatelot vvatelot commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes analysis of URLs with emoji/IDNA domains (e.g. https://xn--3s8h30f.ws/) that failed with a 400/500 error
  • Replaces manual idna.encode conversion with Pydantic AnyHttpUrl, which correctly handles emoji labels that standard IDNA encoding rejects
  • Passes the punycode URL to the worker queue so the scraper also receives a network-compatible URL

Fixes cnumr/EcoIndex#416

Context

When submitting https://xn--3s8h30f.ws/, the WebPage validator stores the URL as Unicode (https://🦊💻.ws/). The previous convert_url_to_punycode helper could not re-encode emoji domains, causing requests.head to fail with InvalidURL.

Test plan

  • Unit tests for punycode conversion (test/bases/ecoindex/backend/test_tasks.py)
  • POST /v1/tasks/ecoindexes/ with {"web_page": {"url": "https://xn--3s8h30f.ws/", "width": 1920, "height": 1080}} returns 201
  • Analysis completes successfully for the queued task

Made with Cursor

WebPage validation stores URLs as Unicode, which breaks requests for emoji
domains like xn--3s8h30f.ws. Use AnyHttpUrl for punycode conversion and pass
the encoded URL to the worker queue.

Fixes cnumr/EcoIndex#416

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Coverage PR 150

Branch coverage •
FileStmtsMissCoverMissing
bases/ecoindex/backend/routers
   tasks.py885439%50–51, 56–58, 94–95, 99–100, 103, 107, 112–113, 116, 118–119, 124–126, 131, 138, 147, 164–167, 172–174, 176, 183–184, 186, 188–189, 191–192, 194, 196, 208–211, 241, 248, 266–269, 274, 276, 281–282, 284
TOTAL164656366% 

Expose SSL, timeout, and DNS errors in the unreachable URL response instead of empty parentheses.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vvatelot
vvatelot merged commit cdf9bd6 into main Jul 15, 2026
6 checks passed
@vvatelot
vvatelot deleted the fix/punycode-emoji-domains branch July 15, 2026 09:01
vvatelot added a commit that referenced this pull request Jul 15, 2026
* fix(api): support emoji and punycode domains in analysis tasks

WebPage validation stores URLs as Unicode, which breaks requests for emoji
domains like xn--3s8h30f.ws. Use AnyHttpUrl for punycode conversion and pass
the encoded URL to the worker queue.

Fixes cnumr/EcoIndex#416

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): include request error details when URL pre-check fails

Expose SSL, timeout, and DNS errors in the unreachable URL response instead of empty parentheses.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
vvatelot added a commit that referenced this pull request Jul 15, 2026
* feat(api): allow choosing MySQL or PostgreSQL via DB_ENGINE

Developers can now pick sqlite, mysql, or postgres at startup through a single DB_ENGINE setting, with Docker Compose profiles and local dev containers aligned on the same configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): support emoji and punycode domains in analysis tasks (#150)

* fix(api): support emoji and punycode domains in analysis tasks

WebPage validation stores URLs as Unicode, which breaks requests for emoji
domains like xn--3s8h30f.ws. Use AnyHttpUrl for punycode conversion and pass
the encoded URL to the worker queue.

Fixes cnumr/EcoIndex#416

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): include request error details when URL pre-check fails

Expose SSL, timeout, and DNS errors in the unreachable URL response instead of empty parentheses.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): keep DATABASE_URL typed as str for ty compatibility

Use an empty default and resolve it in the model validator so type checkers accept Settings().DATABASE_URL where a str is required.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): run alembic migrations from the api project directory

Alembic needs projects/ecoindex_api as the working directory so it can find alembic.ini and load the local .env during init-dev-project.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(api): start dev DB before running alembic migrations

Ensure mysql/postgres containers are up before migration-upgrade and document which DB_HOST to use for local dev versus Docker Compose.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can not analyze website

1 participant