From 89ee20284541340aaa889d39282eb1668eed747f Mon Sep 17 00:00:00 2001 From: Ludovic Vielle Date: Mon, 8 Jun 2026 16:03:14 +0200 Subject: [PATCH] Fix NDA upload to set organization ID Signed-off-by: Ludovic Vielle --- pkg/coredata/migrations/20260608T140141Z.sql | 23 ++++++++++++++++++++ pkg/probo/trust_center_service.go | 19 ++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 pkg/coredata/migrations/20260608T140141Z.sql diff --git a/pkg/coredata/migrations/20260608T140141Z.sql b/pkg/coredata/migrations/20260608T140141Z.sql new file mode 100644 index 000000000..53692a5a5 --- /dev/null +++ b/pkg/coredata/migrations/20260608T140141Z.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 NDA files that were inserted with the nil GID. +-- Before the fix in TrustCenterService.UploadNDA, the OrganizationID field +-- was omitted from the File struct. + +UPDATE files +SET organization_id = tc.organization_id +FROM trust_centers tc +WHERE files.organization_id = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + AND files.id = tc.non_disclosure_agreement_file_id; diff --git a/pkg/probo/trust_center_service.go b/pkg/probo/trust_center_service.go index ad6d346d2..59bd12a8f 100644 --- a/pkg/probo/trust_center_service.go +++ b/pkg/probo/trust_center_service.go @@ -264,15 +264,16 @@ func (s TrustCenterService) UploadNDA( fileID := gid.New(scope.GetTenantID(), coredata.FileEntityType) 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: trustCenter.OrganizationID, + BucketName: s.svc.bucket, + MimeType: mimeType, + FileName: req.FileName, + FileKey: objectKey.String(), + FileSize: *headOutput.ContentLength, + Visibility: coredata.FileVisibilityPrivate, + CreatedAt: now, + UpdatedAt: now, } if err := file.Insert(ctx, conn, scope); err != nil {