openlibhums / openlibhums/janeway

UnicodeDecodeError when clicking edit galley

Open
#1,806 1 comment 0 reactions 1 assignee View on GitHub

@ajrbyers is already working on this.

Since Jul 15, 2026.

bug dev-ready Priority high Size M
Dominant language
Python
Stars
238
Forks
97
Avg merge
9d 1h
Merged PRs (30d)
8

Description

Describe the bug
When an HTML/XML galley file is uploaded with an encoding different than UTF-8, Janeway will throw a server error if a user tries to edit such galley.: UnicodeDecodeError: 'utf-8' codec can't decode byte [...]

Janeway version
v1.3.8

To Reproduce
Steps to reproduce the behavior:

  1. Create a non UTF-8 encoded HTML file
  2. Upload the file as a galley to any article
  3. Hit edit galley
  4. See error

Expected behavior
The edit galley page should still resolve properly, perhpas with a message specifying that the encoding of the file is invalid and suggesting the user to upload a properly encoded version of the file.
Additionally we address this problem at upload time, I can think of two approaches:

  1. Add a form validator that checks the encoding of the file is supported.
  2. Guess the file encoding with a charset detector and transform it into UTF-8 where possible. This however could lead to data-loss or file corruption if we don't guess the encoding correctly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.