fix(events): Handle nullable label and milestone in resource events
GitLab returns null for the label/milestone fields on resource_label_events and resource_milestone_events when the referenced label or milestone has been deleted. This caused deserialization failures during sync. - Add migration 012 to recreate both event tables with nullable label_name, milestone_title, and milestone_id columns (SQLite requires table recreation to alter NOT NULL constraints) - Change GitLabLabelEvent.label and GitLabMilestoneEvent.milestone to Option<> in the Rust types - Update upsert functions to pass through None values correctly - Add tests for null label and null milestone deserialization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,10 @@ const MIGRATIONS: &[(&str, &str)] = &[
|
||||
"011",
|
||||
include_str!("../../migrations/011_resource_events.sql"),
|
||||
),
|
||||
(
|
||||
"012",
|
||||
include_str!("../../migrations/012_nullable_label_milestone.sql"),
|
||||
),
|
||||
];
|
||||
|
||||
/// Create a database connection with production-grade pragmas.
|
||||
|
||||
@@ -82,7 +82,7 @@ pub fn upsert_label_events(
|
||||
issue_id,
|
||||
merge_request_id,
|
||||
event.action,
|
||||
event.label.name,
|
||||
event.label.as_ref().map(|l| l.name.as_str()),
|
||||
actor_id,
|
||||
actor_username,
|
||||
created_at,
|
||||
@@ -123,8 +123,8 @@ pub fn upsert_milestone_events(
|
||||
issue_id,
|
||||
merge_request_id,
|
||||
event.action,
|
||||
event.milestone.title,
|
||||
event.milestone.id,
|
||||
event.milestone.as_ref().map(|m| m.title.as_str()),
|
||||
event.milestone.as_ref().map(|m| m.id),
|
||||
actor_id,
|
||||
actor_username,
|
||||
created_at,
|
||||
|
||||
Reference in New Issue
Block a user