fix: sanitize inverted affiliation dates in git integration - #4529
Conversation
Reject inverted or incomplete project-registry stint date ranges before they are written to member organizations and segment affiliations. Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
Sanitizes invalid affiliation date ranges during new parses and cached snapshot loading.
Changes:
- Adds Pydantic date-range sanitization.
- Tightens the extraction prompt.
- Adds focused unit tests.
The PR title must include a JIRA key, such as (CM-1234).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test_affiliation_date_sanitization.py |
Tests date sanitization and snapshot loading. |
affiliation_service.py |
Requires valid date ordering in extraction prompts. |
affiliation_info.py |
Sanitizes invalid stint dates during validation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
services/apps/git_integration/src/crowdgit/services/affiliation/affiliation_service.py:1056
- This sanitizes only the current repository's affiliations.
exclude_parent_repo_affiliations()subsequently readsparent_registry.snapshotdirectly and compares its unsanitized date-bearing keys. If that legacy parent snapshot contains the same inverted stint, it will not match the child's normalized(None, None)key, so the fork can reapply an affiliation that should have been excluded. Enforce this invariant whenAffiliationOrganizationStintis validated, or sanitize parent snapshots before building their keys.
affiliations = self.normalize_affiliation_dates(affiliations)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
services/apps/git_integration/src/crowdgit/services/affiliation/affiliation_service.py:1056
- This normalizes only the current repository's snapshot.
exclude_parent_repo_affiliationssubsequently loads the parent registry and builds comparison keys from its snapshot without normalization (lines 731–740). If that cached parent snapshot contains an inverted range, the normalized fork key no longer matches it, so an inherited affiliation is incorrectly applied to the fork. Normalize the parent snapshot before constructingparent_stint_keysas well.
affiliations = self.normalize_affiliation_dates(affiliations)
Summary
Project-registry affiliation parsing in git_integration could persist inverted stint date ranges (
dateStart>dateEnd) intomemberOrganizationsandmemberSegmentAffiliations. Those invalid ranges create timeline holes during affiliation refresh and can leave stale activity relations on blocked orgs. This change aligns git_integration with the date validation used elsewhere in the platform.Changes
model_validatoronAffiliationOrganizationStintthat nulls both dates when the range is inverted or whendateEndis set withoutdateStart, matchingsanitizeMemberOrganizationDateRangebehaviordateStart <= dateEnd