Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing a book fails when malformed table of contents data is submitted #10314

Open
jimchamp opened this issue Jan 11, 2025 · 1 comment
Open
Labels
Lead: @cdrini Issues overseen by Drini (Staff: Team Lead & Solr, Library Explorer, i18n) [managed] Module: Table of Contents Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]

Comments

@jimchamp
Copy link
Collaborator

Problem

Using the book edit UI, patrons can add table of contents data to an edition. When this data is formatted properly, a rich table of contents will be displayed on the edition's page.

Unfortunately, if the data is malformed such that it cannot be parsed, the edit operation fails and the patron is shown an unhelpful error page:

image

Here is an example of a malformed table of contents entry:

* | Forward | 1
    ** 1 | | A new chapter | 12
Example well-formed table of contents * | Forward | 1 ** 1 | A new chapter | 12

Removing the second | character from line two corrected the malformed entry.

Reproducing the bug

Using you local development environment:

  1. Go to an edition page and click the "Edit" button to open the edit UI.
  2. Ensure that you click the edition tab (found to the right of the "Work Details" tab.
  3. Paste the malformed table of contents data into the table of contents field.
  4. Submit the form.
  • Expected behavior: You are taken back to the edition page. There is a flash message thanking you for updating the record. The table of contents can now be seen in the details section of the page.
  • Actual behavior: An error page is displayed.

Context

  • Browser (Chrome, Safari, Firefox, etc): Any
  • OS (Windows, Mac, etc): All
  • Logged in (Y/N): Y
  • Environment (prod, dev, local): prod

Breakdown

Requirements Checklist

  • [ ]

Related files

Stakeholders


Instructions for Contributors

  • Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
@jimchamp jimchamp added Type: Bug Something isn't working. [managed] Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Jan 11, 2025
@mekarpeles mekarpeles added Priority: 3 Issues that we can consider at our leisure. [managed] Lead: @cdrini Issues overseen by Drini (Staff: Team Lead & Solr, Library Explorer, i18n) [managed] Module: Table of Contents and removed Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Jan 12, 2025
@mekarpeles
Copy link
Member

mekarpeles commented Jan 12, 2025

Screenshot 2025-01-12 at 2 04 39 PM

/openlibrary/openlibrary/plugins/upstream/table_of_contents.py in from_markdown

L 133        return TocEntry( 

/openlibrary/openlibrary/plugins/upstream/table_of_contents.py in from_markdown

L 48                TocEntry.from_markdown(line) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @cdrini Issues overseen by Drini (Staff: Team Lead & Solr, Library Explorer, i18n) [managed] Module: Table of Contents Needs: Breakdown This big issue needs a checklist or subissues to describe a breakdown of work. [managed] Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]
Projects
None yet
Development

No branches or pull requests

2 participants