Uh oh!
There was an error while loading. Please reload this page.
Fix location area encounters lookup assuming contiguous ids - #1608
Conversation
Same issue as PokeAPI#1567 / PR PokeAPI#1603 (previously fixed in get_pokemon_moves): LocationAreaDetailSerializer.get_encounters looked up Version summaries by list position (id - 1), assuming ids form a contiguous 1-indexed sequence. Any gap in the Version table (e.g. a deleted row) causes the wrong version to be returned, or an IndexError. This is the same root cause reported in PokeAPI#1313 and previously attempted in PR PokeAPI#1314 (closed, unmerged).
Naramsim
commented
Jul 18, 2026
Thanks a lot! |
Uh oh!
There was an error while loading. Please reload this page.
pokeapi-machine-user
commented
Jul 18, 2026
A PokeAPI/api-data refresh has started. In ~45 minutes the staging branch of PokeAPI/api-data will be pushed with the new generated data. |
pokeapi-machine-user
commented
Jul 18, 2026
The updater script has finished its job and has now opened a Pull Request towards PokeAPI/api-data with the updated data. |
Problem
Same root cause as #1567 (fixed in #1603):
LocationAreaDetailSerializer.get_encounterslooks upVersionsummaries by list position (id - 1), assuming the table forms a contiguous 1-indexed sequence.Any gap in the
Versiontable (e.g. a deleted row) causes the wrong version to be returned for an encounter, or raises anIndexError.This was originally reported in #1313 and attempted in #1314, which was closed without merging.
Fix
Same approach as #1603: build a dict keyed by the actual
idinstead of relying on list position.Test plan
test_location_area_encounters_with_non_contiguous_version_ids, which creates and deletes aVersionto force a gap, then asserts thelocation-areaendpoint still returns the correct version.IndexErroragainst the old code and passes with the fix.manage.py test pokemon_v2passes (56 tests).black --checkpasses.