Skip to content

manage_covers.POST silently returns None on malformed input (covers.py) #12755

@tranmin001

Description

@tranmin001

Problem

In openlibrary/plugins/upstream/covers.py, the manage_covers.POST handler silently returns None when the images input is missing the expected - separator. The else branch at line 196-197 only contains # ERROR and pass, so invalid requests fail with no error message or feedback to the user.

Reproducing the bug

sudo docker compose run --rm home python3 -c "
from unittest.mock import patch, MagicMock
import web
app = web.application(('/', 'x'), globals())
app.load({'REQUEST_METHOD': 'POST', 'PATH_INFO': '/'})
with patch('web.input', return_value=web.storage(image=['1', '2', '3'])):
    with patch('openlibrary.plugins.upstream.covers.accounts.get_current_user', return_value=MagicMock()):
        web.ctx.site = MagicMock()
        web.ctx.site.get.return_value = MagicMock()
        from openlibrary.plugins.upstream.covers import manage_covers
        print(manage_covers().POST('/editions/OL1M'))
"
  • Expected behavior: an error response
  • Actual behavior:None returned silently

Screenshot from local environment:

Image

Context

Found in openlibrary/plugins/upstream/covers.py in manage_covers.POST around line 196-197.

Breakdown

Replace # ERROR and pass with an appropriate error response so the user receives feedback when invalid input is submitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Lead: @RayBBIssues overseen by Ray (Onboarding & Documentation Lead) [manages]Module: Cover ServiceCover Store (book covers service)Needs: BreakdownThis big issue needs a checklist or subissues to describe a breakdown of work. [managed]Needs: ResponseIssues which require feedback from leadPriority: 3Issues that we can consider at our leisure. [managed]Type: BugSomething isn't working. [managed]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions