Edit project breaks entirely for project with undefined user

i think stafftest2 needed to be included in the “include” user list, too. i only see tiwane and inatstafftestaccount in the list:

and just to verify, i saw only tiwane and inatstafftestaccount in the project rules of the API response (https://api.inaturalist.org/v1/projects/test-deleted-user-project?rule_details=true), too. here’s a snippet:

"project_observation_rules": [
  {
    "operand_id": 28,
    "id": 837292,
    "operand_type": "User",
    "operator": "observed_by_user?",
    "user": {
      "id": 28,
      "login": "tiwane",
      "spam": false,
      "suspended": false,
      "created_at": "2008-04-03T02:33:23+00:00",
      "login_autocomplete": "tiwane",
      "login_exact": "tiwane",
      "name": "Tony Iwane",
      "name_autocomplete": "Tony Iwane",
      ...
    }
  },
  {
    "operand_id": 180992,
    "id": 837294,
    "operand_type": "User",
    "operator": "observed_by_user?",
    "user": {
      "id": 180992,
      "login": "inatstafftestaccount",
      "spam": false,
      "suspended": false,
      "created_at": "2016-02-18T18:49:28+00:00",
      "login_autocomplete": "inatstafftestaccount",
      "login_exact": "inatstafftestaccount",
      "name": "",
      "name_autocomplete": "",
      ...
    }
  },
  ...
}

It was on the list. It disappeared after I deleted the account.

hmmm… that’s interesting. are there different ways to delete a user? if so, can you tell how the problematic user (1142264) from benarmstrong’s case was deleted? (maybe some methods of user deletion clean up associated records better than others?)

1 Like

Or has the code that cleans up records changed over the time between our last project update and when I discovered the issue and finally fixed it by removing the bad record?

This user has not been an iNat Discord community member for quite a while, and we haven’t updated the 2020 yearlisting much (maybe not even at all, apart from my recent update to fix it) since the start of 2021. So that’s a sizeable timeframe in which the damage may have taken place.

i guess if user cleanup is more robust now, then that might indirectly have solved the problem here. but probably iNat staff will be the only ones who can efficiently find out if there are other projects with deleted users in their include lists, and that could shed light on whether the problem might still be occurring.

1 Like

Could it be that deleting a user when there is a rule to include their observations but they haven’t joined the project causes the problem?

I also tried that and couldn’t replicate.

just to make sure the problem was what we thought it was, here’s another project with the same user in the include user list: https://www.inaturalist.org/projects/discord-inaturalist-june-2020-weekendblitz. @benarmstrong – can you check out the project edit page and see if you run into the same error? (let’s keep the rules on this project as is for now so that tiwane can look at it, if needed.)

1 Like

Yes, it breaks exactly the same way when I click Edit.

Thanks, I’ve added to my weekly report.

By the way, since this was a couple of weeks ago giving people a chance to check the project, and we actually had to edit this project as part of our housekeeping today, it no longer has the bad user ID in it because I had to remove it to be able to edit it.

1 Like

I just wanted to mention how grateful the iNaturalist Discord community is for all the iNat devs who keep things running. This stuff isn’t easy!

Since, even after the latest scheduled maintenance, this issue is still not yet fixed (and I have not yet integrated the feature discussed above into Dronefly that would avoid the issue), I have had to enlist the help of other project admins to run a curl one-liner like the one pisum shared above to fix the remaining Discord iNaturalist projects. This was necessary to finish our extensive set of edits across all 31 of our projects to give all of the projects icons with a consistent style: https://www.inaturalist.org/search?q=inaturalist%20discord

This is an effective workaround even though it’s somewhat involved to guide a non-technical co-admin through the whole process. Still, it does the job for now!

1 Like

This is probably it. The project rule changed but the project was never re-indexed after that, we don’t know why. None of us can reproduce the issue. Can you please message me the username of the deleted account? I can see when it was deleted.

1 Like

Tony, I’m curious if you ever found a reason why these projects broke.

Unrelated to that, but putting to use everything learned from the discussion above, I finally have some Dronefly Discord bot code to make the chore of adding/removing observer project rules easier for our team. I particularly owe thanks to @jcook adding the necessary endpoints to pyinaturalist (not yet released). That made coding this feature a lot easier!

image

We’ll be using this heavily over the next week as we prepare for our next monthly bioblitz, concurrent with the CNC dates.

1 Like

doesn’t seem like there’s going to much more research that can / will be done on this issue. it’s probably time to officially close the thread.