Orphaned identification record returned from API

Example Case

The iNat Identifications page returns 3 records for a particular user identifying anoles on his own observations (https://www.inaturalist.org/identifications?taxon_id=36362&user_id=kyle481&for=self):

However, if I use the API to search for the same set of identifications, I get back 4 records (https://api.inaturalist.org/v1/identifications?own_observation=true&user_id=kyle481&current=true&taxon_id=36362&only_id=true):

{
  "total_results": 4,
  "page": 1,
  "per_page": 30,
  "results": [
    {"id": 239455766},
    {"id": 239448882},
    {"id": 239219132},
    {"id": 239191876}
  ]
}

Here’s an abbreviated version of what /v1/identifications returns for the extra identification 239191876 (https://api.inaturalist.org/v1/identifications/239191876):

{
  "total_results": 1,
  "page": 1,
  "per_page": 30,
  "results": [
    {
      "id": 239191876,
      "uuid": "4130f84c-03b2-4617-8504-6b4162bf8a1f",
      "user": {
        "id": 2564217,
        "login": "kyle481",
        ...
      },
      "created_at": "2022-02-26T09:40:25-05:00",
      ...
      "own_observation": true,
      "taxon_change": null,
      "vision": true,
      "disagreement": null,
      "previous_observation_taxon_id": 116461,
      "spam": false,
      "taxon_id": 116461,
      ...
      "observation": {
        "id": 107478348,
        "site_id": 1,
        "created_at": "2022-02-26T09:40:25.359-05:00",
        ...
        "observed_on": "2022-02-26",
        ...
        "quality_grade": "research",
        "taxon": {
          "id": 36362,
          ...
        },
        ...
      },
      ...
    }
  ]
}

The extra identification is associated with an observation 107478348, which does not exist in the system. (I assume that means the observation existed but was deleted at some point.)

https://www.inaturalist.org/observations/107478348:

https://api.inaturalist.org/v1/observations/107478348:

{
  "total_results": 0,
  "page": 1,
  "per_page": 1,
  "results": []
}

As far as I can tell, the user still exists in the system and does not appear to be suspended.

Discussion

I’m not sure how the identification record was orphaned. I tried creating an observation record with an identification, then deleting the observation, and I saw that my identification was deleted along with the observation.

It seems like whatever allowed the example identification record to not be deleted (when the associated observation was deleted) should be fixed, if possible, and the orphaned identification record and others like it probably need to be cleaned up from the system.

Short of that, the API should probably be modified to prevent orphaned identification records from being returned. (This will prevent inconsistencies such as 3 observations showing up on the Identify screen vs. 4 records returned by the API.)

another example: https://api.inaturalist.org/v1/identifications/243693304 (associated with observation that no longer exists: https://www.inaturalist.org/observations/109202173)