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

Orphaned editions throw IndexError #4051

Closed
cclauss opened this issue Nov 9, 2020 · 6 comments
Closed

Orphaned editions throw IndexError #4051

cclauss opened this issue Nov 9, 2020 · 6 comments
Assignees
Labels
Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] Priority: 2 Important, as time permits. [managed] python Pull requests that update Python code Type: Bug Something isn't working. [managed]

Comments

@cclauss
Copy link
Contributor

cclauss commented Nov 9, 2020

Fixed in #4052

Evidence / Screenshot (if possible)

http://staging.openlibrary.org/books/OL21692921M?debug=true

<class 'IndexError'> at /books/OL21692921M
list index out of range
Python /openlibrary/openlibrary/templates/type/edition/view.html in template, line 9
Web GET http://staging.openlibrary.org/books/OL21692921M

Screenshot 2020-11-09 at 15 43 19

Relevant url?

http://staging.openlibrary.org/books/OL21692921M/Catharisme?debug=true&edition=

Steps to Reproduce

  1. Go to ...
  2. Do ...
  • Actual:
  • Expected:

Details

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

Proposal & Constraints

Related files

Stakeholders

@cclauss cclauss added Type: Bug Something isn't working. [managed] Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Python labels Nov 9, 2020
@cclauss cclauss added this to the Active Sprint milestone Nov 9, 2020
@cclauss cclauss changed the title Python 3: http://staging.openlibrary.org/books/OL21692921M/Catharisme?debug=true&edition= Python 3: IndexError on http://staging.openlibrary.org/books/OL21692921M?debug=true Nov 9, 2020
@mekarpeles mekarpeles added Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] Priority: 2 Important, as time permits. [managed] and removed Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] labels Nov 9, 2020
@cdrini cdrini changed the title Python 3: IndexError on http://staging.openlibrary.org/books/OL21692921M?debug=true Orphaned editions throw IndexError Nov 16, 2020
@cdrini
Copy link
Collaborator

cdrini commented Nov 16, 2020

Updated title; this isn't a Python 3 specific issue

@cclauss
Copy link
Contributor Author

cclauss commented Nov 16, 2020

Fixed in #4052

@cdrini
Copy link
Collaborator

cdrini commented Dec 15, 2020

Here's the code the edit pages use to create a "dummy" work (not committed to db) to normalize rendering. Note the return type of .new is the Work model in this case.

if not work:
# HACK: create dummy work when work is not available
work = web.ctx.site.new('', {
'key': '',
'type': {'key': '/type/work'},
'title': edition.title,
'authors': [{'type': {'key': '/type/author_role'}, 'author': {'key': a['key']}} for a in edition.get('authors', [])],
'subjects': edition.get('subjects', []),
})

@cclauss
Copy link
Contributor Author

cclauss commented Dec 17, 2020

Fixed in #4286

@seabelis
Copy link
Collaborator

@seabelis seabelis reopened this May 15, 2021
@cdrini
Copy link
Collaborator

cdrini commented Jul 9, 2021

Created a separate issue for this, since the cause of the error is very different this time 👍 #5404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @mekarpeles Issues overseen by Mek (Staff: Program Lead) [managed] Priority: 2 Important, as time permits. [managed] python Pull requests that update Python code Type: Bug Something isn't working. [managed]
Projects
None yet
Development

No branches or pull requests

4 participants