Repository: internetarchive/openlibrary

Issue:
"/openlibrary/openlibrary/templates/type/edition/view.html: error in processing template: AttributeError: 'NoneType' object has no attribute 'get' (falling back to default template) Unable to render this page."
<!-- What problem are we solving? What does the experience look like today? What are the symptoms? -->
Error when viewing some editions. May be solr related. It seems to happen with newer records. Maybe those that have not been indexed yet.
### Evidence / Screenshot (if possible)

### Relevant url?
<!-- `https://openlibrary.org/...` -->
https://openlibrary.org/books/OL35552510M/Community-Based_Monitoring_in_the_Arctic?debug=true

### Steps to Reproduce
<!-- What steps caused you to find the bug? -->
1. Go to ...https://openlibrary.org/books/OL35552510M
2. Do ...see error

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: 
```
"/openlibrary/openlibrary/templates/type/edition/view.html: error in processing template: AttributeError: 'NoneType' object has no attribute 'get' (falling back to default template)
Unable to render this page."
```
* Expected: no error.

### Details

- **Logged in (Y/N)?**
- **Browser type/version?**
- **Operating system?**
- **Environment (prod/dev/local)?** prod
<!-- If not sure, put prod -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->
@mekarpeles @cdrini @jimchamp 


Discussion:
Related to https://github.com/internetarchive/openlibrary/issues/6126?

Resolving patch:
diff --git a/openlibrary/plugins/upstream/models.py b/openlibrary/plugins/upstream/models.py
--- a/openlibrary/plugins/upstream/models.py
+++ b/openlibrary/plugins/upstream/models.py
@@ -728,15 +728,19 @@ def get_sorted_editions(self, ebooks_only=False, limit=10000):
         db_query = {"type": "/type/edition", "works": self.key, "limit": limit}
 
         if ebooks_only:
-            from openlibrary.book_providers import get_book_providers
             edition_keys = []
-            # Always use solr data whether it's up to date or not
-            # to determine which providers this book has
-            # We only make additional queries when a
-            # trusted book provider identifier is present
-            for provider in get_book_providers(self._solr_data):
-                query = {**db_query, **provider.editions_query}
-                edition_keys += web.ctx.site.things(query)
+            if self._solr_data:
+                from openlibrary.book_providers import get_book_providers
+                # Always use solr data whether it's up to date or not
+                # to determine which providers this book has
+                # We only make additional queries when a
+                # trusted book provider identifier is present
+                for provider in get_book_providers(self._solr_data):
+                    query = {**db_query, **provider.editions_query}
+                    edition_keys += web.ctx.site.things(query)
+            else:
+                db_query["ocaid~"] = "*"
+
         else:
             solr_is_up_to_date = (
                 self._solr_data


Test patch: