internetarchive / internetarchive/openlibrary

List `/embed` and `/export` URLs do not work if list title slug is missing

Open
#5,707 1 comment 0 reactions 0 assignees View on GitHub
Lead: @jimchamp Priority: 3 Type: Bug
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 19h
Merged PRs (30d)
138

Description

The paths for embedding and exporting lists are generally defined as follows:
Exports: `/people/{username}/lists/{list_olid}/export`
Embed: `/people/{username}/lists/{list_olid}/embed`

Navigating to either of these URLs redirects to the list page, with `export` or `embed` being replaced with the list's name (URL encoded).

The links work correctly if the encoded list name is included in the URL:
Exports: `/people/{username}/lists/{list_olid}/{list_name}/export`
Embed: `/people/{username}/lists/{list_olid}/{list_name}/embed`

### Evidence / Screenshot (if possible)

### Relevant url?

https://openlibrary.org/people/jachamp/lists/OL201547L/export?format=json ([archived](https://web.archive.org/web/20220315201138/https://openlibrary.org/people/jachamp/lists/OL201547L/Why_am_I_here?format=json))

### Steps to Reproduce

1. Navigate to the JSON export link listed above.

* Actual: Redirected to the list page.
* Expected: Served a JSON representation of the list.

### Details

- **Logged in (Y/N)?** N/A
- **Browser type/version?** N/A
- **Operating system?** N/A
- **Environment (prod/dev/local)?** prod

### Proposal & Constraints

I'm not even sure if this is a bug. The export links on list pages use the longer, properly working, URLs. I didn't see any embed links on the page.

If the current behavior is expected, we should, at the very least, add some documentation about the routing. How and where are the controllers' path definitions being overwritten (if that's what is happening)? Are other controller's paths misleading?

### Related files

/openlibrary/plugins/openlibrary/lists.py:
https://github.com/internetarchive/openlibrary/blob/f4b2f8f4aebaae550f44feecaf22b3f75aac64a5/openlibrary/plugins/openlibrary/lists.py#L447-#L483

### Stakeholders

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.