WordPress / openverse

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Home Page:https://openverse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`/api/api/admin/media_report.py, line 387, in change_view` can fail if the tag does not have a provider

sarayourfriend opened this issue · comments

Description

This line fails for tags without a provider

tags_by_provider.setdefault(tag["provider"], []).append(text)

You cannot visit http://localhost:50280/admin/api/image//change/ because of this.

Reproduction

  1. Run the API and `just api/init`
  2. create a report for image 69dd41c2-beac-4640-baa5-8956a74bcd0f
  3. Visit the admin API image view for that image and see the crash

To fix this, change the linked line above to tag.get("provider") and correctly handle the None case.

Additional context

Found while reviewing #4415 but is unrelated to that PR.

This also seems like an underlying data consistency issue we should address 😅 I (clearly inaccurately) made the assumption that all tag values have a provider associated with them, and I think they should (or at least default to the record's provider).

@AetherUnbound would you like to keep this open to track the fixes towards the underlying data inconsistency?

I'll make a new issue for it today!