Repository navigation
impr(jira): replace the mass overwrite with diff method - #121198
Conversation
ceorourke
left a comment
There was a problem hiding this comment.
lgtm, nice test coverage. I could see putting it behind a flag and logging the omissions if you wanted to be super safe, but since this is an even less destructive change than we have today it seems fine
| "mappedColumnLabel": _("Jira Project"), | ||
| "formatMessageValue": False, | ||
| # For the frontend form to support explicit removals (upsert + tombstone) | ||
| "supportsExplicitRemovals": True, |
There was a problem hiding this comment.
Is this something useful outside of just Jira config mapping updates? Is the plan to widen this to all other project management integrations in the future? They seem susceptible to the same type of IEP deletion issue.
There was a problem hiding this comment.
potentially, but that would also likely explode the diff on this, so I wanted to keep the scope targeted.
| def _validate_project_status_mappings( | ||
| project_mappings: Mapping[str, Any], | ||
| ) -> dict[str, dict[str, str]]: | ||
| project_mappings: object, |
There was a problem hiding this comment.
Can we be more explicit with the type here? Having this as object seems relatively unsafe.
There was a problem hiding this comment.
it's because the endpoint that calls into this doesn't have a validator (the endpoint is used by all integrations so the input shapes vary wildly). We have guards underneath to assert the type to be a mapping/dict so that's the validation p much
| tombstones.add(external_id) | ||
| continue | ||
|
|
||
| if not isinstance(statuses, Mapping) or not ( |
There was a problem hiding this comment.
I think this sort of type checking and validation should live in a a validation function, or in a validator at the API level. Separating these would make this more testable and allow us to more easily pass around typed objects in the code than what we're doing now.
There was a problem hiding this comment.
yeah this function is behaving like a validator. It's because the endpoint that calls into this is used across integrations there's not an easy way to apply an API level validator/serializer that applies for all integrations.
I think it's okay to have the validator be at the integration level, but I can try and strengthen the typing we return.
da0e580 to
ab70b06
Compare
8515d1e to
da0e580
Compare
Summary
Currently the frontend payload comes in like
These entries each become an
IntegrationExternalProject(IEP) row and currently we just replace ALL the current IEP entries for an integration with the latest ones we receive from this config. That means if a project is missing from the config that means we should delete it.This backend change is to support a new frontend format we want to send instead of
where a project having a null mapping means we should delete its IEP. And if it's omitted means we should do nothing. This makes deletions an explicit action versus if somehow we accidentally sent an empty {} that would delete the entire config.
thoughts