/v1/taxa/autocomplete taxon_id returning a result without that id in ancestor_ids

We found a bug in the new taxon_id support in the /v1/taxa/autocomplete endpoint. Here’s a test URL, specifying taxon_id=7823 (Corvidae) and q=fish:


Surprisingly, this returns 2 records, the first of which does not include 7823 in the ancestor_ids and the second of which does.

  • Actinopterygii (Ray-finned Fishes) with "ancestor_ids":[48460,1,2,355675,47178]
  • Corvus ossifragus (Fish Crow) with "ancestor_ids":[48460,1,2,355675,3,7251,7823,7998,8001]

Compare the results with the return from the /v1/taxa endpoint for the same query:


This correctly only matches the 2nd record above, the “Fish crow” record.

As a workaround, I will iterate over the returned records and return the first one that contains the ancestor taxon_id in ancestor_ids.

Please look into this & fix.


Likely the same bug as https://forum.inaturalist.org/t/v1-taxa-autocomplete-returning-results-without-requested-ranks/7183/4 . Hopefully this is fixed now

1 Like

This one is fixed, too. I have just confirmed it after removing my workaround. Thanks.