From 8dbfa35382c4dd404f9a10963757aad3b9289e6b Mon Sep 17 00:00:00 2001 From: Ludovic Vielle Date: Fri, 12 Jun 2026 09:45:04 +0200 Subject: [PATCH] Fix trust center file creation in console Signed-off-by: Ludovic Vielle --- pkg/coredata/migrations/20260612T074402Z.sql | 23 +++++++++++++++++++ pkg/probo/document_service.go | 19 +++++++-------- pkg/probo/framework_service.go | 19 +++++++-------- ...ty_business_associate_agreement_service.go | 19 +++++++-------- ...rd_party_data_privacy_agreement_service.go | 19 +++++++-------- pkg/probo/trust_center_file_service.go | 19 +++++++-------- 6 files changed, 73 insertions(+), 45 deletions(-) create mode 100644 pkg/coredata/migrations/20260612T074402Z.sql diff --git a/pkg/coredata/migrations/20260612T074402Z.sql b/pkg/coredata/migrations/20260612T074402Z.sql new file mode 100644 index 000000000..1613dac0d --- /dev/null +++ b/pkg/coredata/migrations/20260612T074402Z.sql @@ -0,0 +1,23 @@ +-- Copyright (c) 2026 Probo Inc . +-- +-- Permission to use, copy, modify, and/or distribute this software for any +-- purpose with or without fee is hereby granted, provided that the above +-- copyright notice and this permission notice appear in all copies. +-- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +-- PERFORMANCE OF THIS SOFTWARE. + +-- Backfill organization_id on compliance page file uploads that were inserted +-- with the nil GID. Before the fix in TrustCenterFileService.uploadFile, the +-- OrganizationID field was omitted from the File struct. + +UPDATE files +SET organization_id = o.id +FROM organizations o +WHERE files.organization_id = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + AND files.tenant_id = o.tenant_id; diff --git a/pkg/probo/document_service.go b/pkg/probo/document_service.go index 6bf5a5b76..45047b42c 100644 --- a/pkg/probo/document_service.go +++ b/pkg/probo/document_service.go @@ -2212,15 +2212,16 @@ func (s *DocumentService) BuildAndUploadExport(ctx context.Context, scope coreda now := time.Now() file := coredata.File{ - ID: gid.New(exportJob.ID.TenantID(), coredata.FileEntityType), - BucketName: s.svc.bucket, - MimeType: "application/zip", - FileName: fmt.Sprintf("Documents Export %s.zip", now.Format("2006-01-02")), - FileKey: uuid.String(), - FileSize: fileInfo.Size(), - Visibility: coredata.FileVisibilityPrivate, - CreatedAt: now, - UpdatedAt: now, + ID: gid.New(exportJob.ID.TenantID(), coredata.FileEntityType), + OrganizationID: organizationID, + BucketName: s.svc.bucket, + MimeType: "application/zip", + FileName: fmt.Sprintf("Documents Export %s.zip", now.Format("2006-01-02")), + FileKey: uuid.String(), + FileSize: fileInfo.Size(), + Visibility: coredata.FileVisibilityPrivate, + CreatedAt: now, + UpdatedAt: now, } if err := file.Insert(ctx, tx, scope); err != nil { diff --git a/pkg/probo/framework_service.go b/pkg/probo/framework_service.go index 661841407..faea5c8f7 100644 --- a/pkg/probo/framework_service.go +++ b/pkg/probo/framework_service.go @@ -802,15 +802,16 @@ func (s *FrameworkService) BuildAndUploadExport(ctx context.Context, scope cored now := time.Now() file := coredata.File{ - ID: gid.New(exportJob.ID.TenantID(), coredata.FileEntityType), - BucketName: s.svc.bucket, - MimeType: "application/zip", - FileName: fmt.Sprintf("Framework Export %s.zip", now.Format("2006-01-02")), - FileKey: uuid.String(), - FileSize: fileInfo.Size(), - Visibility: coredata.FileVisibilityPrivate, - CreatedAt: now, - UpdatedAt: now, + ID: gid.New(exportJob.ID.TenantID(), coredata.FileEntityType), + OrganizationID: framework.OrganizationID, + BucketName: s.svc.bucket, + MimeType: "application/zip", + FileName: fmt.Sprintf("Framework Export %s.zip", now.Format("2006-01-02")), + FileKey: uuid.String(), + FileSize: fileInfo.Size(), + Visibility: coredata.FileVisibilityPrivate, + CreatedAt: now, + UpdatedAt: now, } if err := file.Insert(ctx, tx, scope); err != nil { diff --git a/pkg/probo/third_party_business_associate_agreement_service.go b/pkg/probo/third_party_business_associate_agreement_service.go index ea91542b8..78f226068 100644 --- a/pkg/probo/third_party_business_associate_agreement_service.go +++ b/pkg/probo/third_party_business_associate_agreement_service.go @@ -156,15 +156,16 @@ func (s ThirdPartyBusinessAssociateAgreementService) Upload( thirdPartyBusinessAssociateAgreementID := gid.New(scope.GetTenantID(), coredata.ThirdPartyBusinessAssociateAgreementEntityType) file = &coredata.File{ - ID: fileID, - BucketName: s.svc.bucket, - MimeType: mimeType, - FileName: req.FileName, - FileKey: objectKey.String(), - FileSize: *headOutput.ContentLength, - Visibility: coredata.FileVisibilityPrivate, - CreatedAt: now, - UpdatedAt: now, + ID: fileID, + OrganizationID: thirdParty.OrganizationID, + BucketName: s.svc.bucket, + MimeType: mimeType, + FileName: req.FileName, + FileKey: objectKey.String(), + FileSize: *headOutput.ContentLength, + Visibility: coredata.FileVisibilityPrivate, + CreatedAt: now, + UpdatedAt: now, } thirdPartyBusinessAssociateAgreement = &coredata.ThirdPartyBusinessAssociateAgreement{ diff --git a/pkg/probo/third_party_data_privacy_agreement_service.go b/pkg/probo/third_party_data_privacy_agreement_service.go index d2a1968f8..94af520e4 100644 --- a/pkg/probo/third_party_data_privacy_agreement_service.go +++ b/pkg/probo/third_party_data_privacy_agreement_service.go @@ -156,15 +156,16 @@ func (s ThirdPartyDataPrivacyAgreementService) Upload( fileID := gid.New(scope.GetTenantID(), coredata.FileEntityType) thirdPartyDataPrivacyAgreementID := gid.New(scope.GetTenantID(), coredata.ThirdPartyDataPrivacyAgreementEntityType) file = &coredata.File{ - ID: fileID, - BucketName: s.svc.bucket, - MimeType: mimeType, - FileName: req.FileName, - FileKey: objectKey.String(), - FileSize: *headOutput.ContentLength, - Visibility: coredata.FileVisibilityPrivate, - CreatedAt: now, - UpdatedAt: now, + ID: fileID, + OrganizationID: thirdParty.OrganizationID, + BucketName: s.svc.bucket, + MimeType: mimeType, + FileName: req.FileName, + FileKey: objectKey.String(), + FileSize: *headOutput.ContentLength, + Visibility: coredata.FileVisibilityPrivate, + CreatedAt: now, + UpdatedAt: now, } thirdPartyDataPrivacyAgreement = &coredata.ThirdPartyDataPrivacyAgreement{ diff --git a/pkg/probo/trust_center_file_service.go b/pkg/probo/trust_center_file_service.go index ebccdc43f..aed5a86b2 100644 --- a/pkg/probo/trust_center_file_service.go +++ b/pkg/probo/trust_center_file_service.go @@ -400,15 +400,16 @@ func (s TrustCenterFileService) uploadFile( } fileRecord := &coredata.File{ - ID: fileID, - BucketName: s.svc.bucket, - MimeType: contentType, - FileName: filename, - FileKey: objectKey.String(), - FileSize: fileSize, - Visibility: coredata.FileVisibilityPrivate, - CreatedAt: now, - UpdatedAt: now, + ID: fileID, + OrganizationID: organizationID, + BucketName: s.svc.bucket, + MimeType: contentType, + FileName: filename, + FileKey: objectKey.String(), + FileSize: fileSize, + Visibility: coredata.FileVisibilityPrivate, + CreatedAt: now, + UpdatedAt: now, } if err := fileRecord.Insert(ctx, tx, scope); err != nil {