Skip to content

compute_question_set_hash raises UnicodeEncodeError for a question with a lone-surrogate escape #757

Open

Description

@antonwolfy

compute_question_set_hash in dokimi/dokimi/orchestrator/pipeline.py:35 joins the sorted id:question fingerprints and encodes them with .encode("utf-8"). A questions file with a \ud800 or \udcff JSON escape loads as a lone surrogate. Repro: compute_question_set_hash([{'id': 'q', 'question': json.loads('"n\\ud800"')}]) raises UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position N: surrogates not allowed. Fix: .encode('utf-8', 'surrogatepass'), as #720 does for the other digests of parsed data; the hash of every question set that encodes today is unchanged.

Found while fixing #720. The fix's PR is #761.

Activity

  1. self-assigned this
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions