Skip to content

Fix UnicodeDecodeError when parsing WordPress titles containing emoji - #5589

Open
ak5869 wants to merge 1 commit into
WordPress:mainfrom
ak5869:fix/wordpress-title-emoji-parsing
Open

Fix UnicodeDecodeError when parsing WordPress titles containing emoji#5589
ak5869 wants to merge 1 commit into
WordPress:mainfrom
ak5869:fix/wordpress-title-emoji-parsing

Conversation

@ak5869

@ak5869 ak5869 commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #1550 by @aelhaddadi715-beep

Description

lxml.html.fromstring raises a UnicodeDecodeError when parsing WordPress
photo titles that contain certain emoji, causing the title to be silently
dropped (set to None) instead of saved.

This adds a fallback: when the UnicodeDecodeError is caught, the title is
instead cleaned using a regex-based HTML tag strip, which operates on the
original string and never re-encodes it — so the emoji is preserved
correctly.

Testing Instructions

Run the WordPress provider tests:
just test tests/dags/providers/provider_api_scripts/test_wordpress.py

A new test, test_get_title_handles_emoji, covers a title containing an
emoji and confirms it comes through unchanged.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.

@ak5869
ak5869 requested a review from a team as a code owner July 9, 2026 07:56
@ak5869
ak5869 requested review from krysal and obulat and removed request for a team July 9, 2026 07:56
@openverse-bot openverse-bot added 🧱 stack: catalog Related to the catalog and Airflow DAGs 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository labels Jul 9, 2026
@openverse-bot openverse-bot moved this to 👀 Needs Review in Openverse PRs Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: catalog Related to the catalog and Airflow DAGs

Projects

Status: 👀 Needs Review

Development

Successfully merging this pull request may close these issues.

Get titles/text with emojis

2 participants