From 0826f28867e0940e4f82b65b0618d676d866f644 Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Mon, 13 Apr 2026 14:02:56 +0200 Subject: [PATCH] Fix missing fields in MCP type serializers Framework was missing OrganizationID, Task was missing MeasureID and AssignedToID, Asset was missing SnapshotID, AuditLogEntry was missing Metadata, and Obligation was missing SourceID. All these fields were defined in the MCP generated types but never set by their converters. Signed-off-by: Sacha Al Himdani --- pkg/server/api/mcp/v1/types/asset.go | 9 ++++++++- pkg/server/api/mcp/v1/types/audit_log_entry.go | 13 ++++++++++++- pkg/server/api/mcp/v1/types/framework.go | 11 ++++++----- pkg/server/api/mcp/v1/types/obligation.go | 9 ++++++++- pkg/server/api/mcp/v1/types/task.go | 2 ++ 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pkg/server/api/mcp/v1/types/asset.go b/pkg/server/api/mcp/v1/types/asset.go index a0e029c11..447efdf0c 100644 --- a/pkg/server/api/mcp/v1/types/asset.go +++ b/pkg/server/api/mcp/v1/types/asset.go @@ -20,7 +20,7 @@ import ( ) func NewAsset(a *coredata.Asset) *Asset { - return &Asset{ + asset := &Asset{ ID: a.ID, Name: a.Name, Amount: a.Amount, @@ -31,6 +31,13 @@ func NewAsset(a *coredata.Asset) *Asset { CreatedAt: a.CreatedAt, UpdatedAt: a.UpdatedAt, } + + if a.SnapshotID != nil { + s := a.SnapshotID.String() + asset.SnapshotID = &s + } + + return asset } func NewListAssetsOutput(assetPage *page.Page[*coredata.Asset, coredata.AssetOrderField]) ListAssetsOutput { diff --git a/pkg/server/api/mcp/v1/types/audit_log_entry.go b/pkg/server/api/mcp/v1/types/audit_log_entry.go index 56aed32be..a279254fd 100644 --- a/pkg/server/api/mcp/v1/types/audit_log_entry.go +++ b/pkg/server/api/mcp/v1/types/audit_log_entry.go @@ -15,12 +15,14 @@ package types import ( + "encoding/json" + "go.probo.inc/probo/pkg/coredata" "go.probo.inc/probo/pkg/page" ) func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry { - return &AuditLogEntry{ + entry := &AuditLogEntry{ ID: e.ID, OrganizationID: e.OrganizationID, ActorID: e.ActorID, @@ -30,6 +32,15 @@ func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry { ResourceID: e.ResourceID, CreatedAt: e.CreatedAt, } + + if len(e.Metadata) > 0 { + var m map[string]any + if json.Unmarshal(e.Metadata, &m) == nil { + entry.Metadata = &m + } + } + + return entry } func NewListAuditLogEntriesOutput(p *page.Page[*coredata.AuditLogEntry, coredata.AuditLogEntryOrderField]) ListAuditLogEntriesOutput { diff --git a/pkg/server/api/mcp/v1/types/framework.go b/pkg/server/api/mcp/v1/types/framework.go index d1f4a3dca..c46eb841f 100644 --- a/pkg/server/api/mcp/v1/types/framework.go +++ b/pkg/server/api/mcp/v1/types/framework.go @@ -21,11 +21,12 @@ import ( func NewFramework(f *coredata.Framework) *Framework { return &Framework{ - ID: f.ID, - Name: f.Name, - Description: f.Description, - CreatedAt: f.CreatedAt, - UpdatedAt: f.UpdatedAt, + ID: f.ID, + OrganizationID: f.OrganizationID, + Name: f.Name, + Description: f.Description, + CreatedAt: f.CreatedAt, + UpdatedAt: f.UpdatedAt, } } diff --git a/pkg/server/api/mcp/v1/types/obligation.go b/pkg/server/api/mcp/v1/types/obligation.go index 9494dc815..a3fb91494 100644 --- a/pkg/server/api/mcp/v1/types/obligation.go +++ b/pkg/server/api/mcp/v1/types/obligation.go @@ -20,7 +20,7 @@ import ( ) func NewObligation(o *coredata.Obligation) *Obligation { - return &Obligation{ + obligation := &Obligation{ ID: o.ID, OrganizationID: o.OrganizationID, SnapshotID: o.SnapshotID, @@ -37,6 +37,13 @@ func NewObligation(o *coredata.Obligation) *Obligation { CreatedAt: o.CreatedAt, UpdatedAt: o.UpdatedAt, } + + if o.SourceID != nil { + s := o.SourceID.String() + obligation.SourceID = &s + } + + return obligation } func NewListObligationsOutput(obligationPage *page.Page[*coredata.Obligation, coredata.ObligationOrderField]) ListObligationsOutput { diff --git a/pkg/server/api/mcp/v1/types/task.go b/pkg/server/api/mcp/v1/types/task.go index b6776120d..2b4fe1763 100644 --- a/pkg/server/api/mcp/v1/types/task.go +++ b/pkg/server/api/mcp/v1/types/task.go @@ -23,12 +23,14 @@ func NewTask(t *coredata.Task) *Task { return &Task{ ID: t.ID, OrganizationID: t.OrganizationID, + MeasureID: t.MeasureID, Name: t.Name, Description: t.Description, State: t.State, Priority: t.Priority, Rank: t.Rank, TimeEstimate: t.TimeEstimate, + AssignedToID: t.AssignedToID, CreatedAt: t.CreatedAt, UpdatedAt: t.UpdatedAt, Deadline: t.Deadline,