-
Notifications
You must be signed in to change notification settings - Fork 7
Description
The DS App Sync Agencies Update Task is producing a 500 Internal Server Error. Checking the Digital Ocean logs, I notice this:
Jan 01 12:55:47 sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'agencies' expected to update 3 row(s); 2 were matched.
The key is likely in this entry in tasks__log:
Updating agencies with the following ds_app_ids: [8, 9, 17652]
It seems that the agency sync task is expecting to update three, but only two exist in the DS Database. In this case, ID 17652 (Northern Lancaster County Regional Police Department), which the change_log shows as having been deleted on 2025-09-12.
The short term fix for this would be to delete the app link in SM and have it recreate. But we don't have a guarantee that the same thing would not occur again. And we'd need to determine if we want to simply address these when they occur manually, or develop a way to make the app more robust.
Currently, the app sync is brittle. It assumes that the DS database perfectly mirrors SM -- or that if it doesn't, it is because there is something in SM that hasn't yet propagated to DS. We would need to update the endpoint logic on both ends such that if an entry is removed from DS but not from SM, SM will recreate it, and update the link between the SM ID and DS ID with the new DS ID. That's more logic, and we may not want that, especially since this has so far only occurred once in 4 months.