Skip to content

fix: sanitize inverted affiliation dates in git integration - #4529

Merged
skwowet merged 5 commits into
mainfrom
fix/git-integration-affiliation-date-sanitization
Aug 28, 2026
Merged

fix: sanitize inverted affiliation dates in git integration#4529
skwowet merged 5 commits into
mainfrom
fix/git-integration-affiliation-date-sanitization

Conversation

@skwowet

@skwowet skwowet commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Project-registry affiliation parsing in git_integration could persist inverted stint date ranges (dateStart > dateEnd) into memberOrganizations and memberSegmentAffiliations. 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

  • Add a Pydantic model_validator on AffiliationOrganizationStint that nulls both dates when the range is inverted or when dateEnd is set without dateStart, matching sanitizeMemberOrganizationDateRange behavior
  • Sanitization runs on new LLM parses and when cached registry snapshots are reloaded
  • Tighten the affiliation extraction prompt to require dateStart <= dateEnd
  • Add unit tests for inverted ranges, end-without-start, valid ranges, and snapshot round-trip loading

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>
Copilot AI balanced review requested due to automatic review settings August 28, 2026 13:09
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings August 28, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread services/apps/git_integration/src/crowdgit/models/affiliation_info.py Outdated
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 28, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 28, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 reads parent_registry.snapshot directly 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 when AffiliationOrganizationStint is validated, or sanitize parent snapshots before building their keys.
            affiliations = self.normalize_affiliation_dates(affiliations)

Copilot AI review requested due to automatic review settings August 28, 2026 13:36
@skwowet
skwowet merged commit 636d4ce into main Aug 28, 2026
12 checks passed
@skwowet
skwowet deleted the fix/git-integration-affiliation-date-sanitization branch August 28, 2026 13:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_affiliations subsequently 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 constructing parent_stint_keys as well.
            affiliations = self.normalize_affiliation_dates(affiliations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants