Skip to content

Commit 9ab96dc

Browse files
committed
feat(file): add object_uid FK column and AIP-122 resource name support (#323)
**Because** - Files created from blob storage uploads need a proper foreign key relationship to the object table - The API needs to return AIP-122 compliant resource names (e.g., `namespaces/{ns}/objects/{id}`) instead of raw UIDs - The protobuf contract has changed from `object_uid` to `object` resource name and from `knowledge_base_ids` to `knowledge_bases` resource names - The Object proto needs to use AIP-compliant `owner_name` and `creator_name` instead of raw namespace/creator UIDs **This commit** - Adds database migration 000055 to add `object_uid` FK column to the file table with backfill from storage_path matching - Updates `FileModel` to include `ObjectUID` foreign key field - Refactors `CreateFile` to: - Parse `knowledge_base` as a resource name and extract ID using `resource.ExtractResourceID()` - Parse `object` as a resource name (format: `namespaces/{ns}/objects/{id}`) and look up by hash-based ID - Store `ObjectUID` FK when creating files from uploaded objects - Return `Object` as AIP-122 resource name instead of `ObjectUid` - Return `KnowledgeBases` as resource names instead of `KnowledgeBaseIds` - Return `Collections` instead of `CollectionIds` - Refactors `ListFiles` to populate object resource names from the new FK relationship - Updates `TurnObjectInDBToObjectInProto` to return: - `OwnerName` as `namespaces/{namespace_uid}` instead of raw `NamespaceId` - `CreatorName` as `users/{creator_uid}` instead of raw `Creator` - Updates protogen-go dependency to latest version with flattened package structure
1 parent dbde71a commit 9ab96dc

File tree

19 files changed

+375
-150
lines changed

19 files changed

+375
-150
lines changed

config/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ openfga:
8181
host: openfga
8282
port: 8081
8383
cache:
84-
enabled: false
84+
enabled: true
8585
ttl: 60 # Permission cache TTL in seconds
8686
minio:
8787
host: minio

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ require (
1313
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
1414
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1
1515
github.com/iancoleman/strcase v0.3.0
16-
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260122065215-c32ea2feec1f
17-
github.com/instill-ai/x v0.10.1-alpha.0.20260122090555-bea4f728b22c
16+
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260125053435-9764054668e5
17+
github.com/instill-ai/x v0.10.1-alpha.0.20260125054429-74b22dd4e0e8
1818
github.com/knadh/koanf v1.5.0
1919
github.com/mennanov/fieldmask-utils v1.1.2
2020
github.com/milvus-io/milvus/client/v2 v2.6.1
@@ -221,3 +221,5 @@ require (
221221
k8s.io/apimachinery v0.32.3 // indirect
222222
sigs.k8s.io/yaml v1.4.0 // indirect
223223
)
224+
225+
replace github.com/instill-ai/protogen-go => ../protogen-go

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS
419419
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
420420
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
421421
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
422-
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260122065215-c32ea2feec1f h1:Ypnhf9ywdC2z8YLtSZytFZJjlDYH7sNDpfNv1Ul8Zpw=
423-
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20260122065215-c32ea2feec1f/go.mod h1:bCnBosofpaUxKBuTTJM3/I3thAK37kvfBnKByjnLsl4=
424422
github.com/instill-ai/x v0.10.1-alpha.0.20260122090555-bea4f728b22c h1:9Z3NbM6Elzh1zlOGc7PKNP52vQPuM3pwxuj2Zsoh+aE=
425423
github.com/instill-ai/x v0.10.1-alpha.0.20260122090555-bea4f728b22c/go.mod h1:/xG0LMh43kyyK9jXGtV/JGd5p9GVcreSZ6GRGVbALEU=
424+
github.com/instill-ai/x v0.10.1-alpha.0.20260125054429-74b22dd4e0e8 h1:siGEvzgpsgvezvjJKnEv8p0s5yRn8e5tOXgkuGdCeyA=
425+
github.com/instill-ai/x v0.10.1-alpha.0.20260125054429-74b22dd4e0e8/go.mod h1:/xG0LMh43kyyK9jXGtV/JGd5p9GVcreSZ6GRGVbALEU=
426426
github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI=
427427
github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
428428
github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk=
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Remove object_uid column and index from file table
2+
DROP INDEX IF EXISTS idx_file_object_uid;
3+
ALTER TABLE file DROP COLUMN IF EXISTS object_uid;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- Add object_uid foreign key column to file table
2+
-- This establishes a proper relationship between files and their blob storage objects
3+
ALTER TABLE file ADD COLUMN object_uid UUID REFERENCES object(uid) ON DELETE SET NULL;
4+
5+
-- Create index for efficient joins when looking up object information for files
6+
CREATE INDEX idx_file_object_uid ON file(object_uid);
7+
8+
-- Backfill existing files: match files to objects by storage_path
9+
-- Both file.storage_path and object.storage_path use the same format
10+
UPDATE file f
11+
SET object_uid = o.uid
12+
FROM object o
13+
WHERE f.storage_path IS NOT NULL
14+
AND f.storage_path != ''
15+
AND o.storage_path = f.storage_path;

pkg/db/migration/migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
// TargetSchemaVersion determines the database schema version.
12-
const TargetSchemaVersion uint = 54
12+
const TargetSchemaVersion uint = 55
1313

1414
type migration interface {
1515
Migrate() error

pkg/handler/chunk.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
artifactpb "github.com/instill-ai/protogen-go/artifact/v1alpha"
1919
errorsx "github.com/instill-ai/x/errors"
2020
logx "github.com/instill-ai/x/log"
21+
"github.com/instill-ai/x/resource"
2122
)
2223

2324
// parseChunkFromName parses a resource name of format "namespaces/{namespace}/files/{file}/chunks/{chunk}"
@@ -72,12 +73,12 @@ func convertToProtoChunk(chunk repository.ChunkModel, namespaceID, fileID string
7273

7374
pbChunk := &artifactpb.Chunk{
7475
Name: resourceName,
75-
Id: chunk.ID,
76-
Retrievable: chunk.Retrievable,
77-
Tokens: uint32(chunk.Tokens),
78-
CreateTime: timestamppb.New(*chunk.CreateTime),
79-
OriginalFileId: chunk.FileUID.String(),
80-
Type: chunkType,
76+
Id: chunk.ID,
77+
Retrievable: chunk.Retrievable,
78+
Tokens: uint32(chunk.Tokens),
79+
CreateTime: timestamppb.New(*chunk.CreateTime),
80+
OriginalFile: fmt.Sprintf("namespaces/%s/files/%s", namespaceID, chunk.FileUID.String()),
81+
Type: chunkType,
8182
}
8283

8384
// Set markdown reference for all chunk types (content, summary, augmented)
@@ -401,9 +402,11 @@ func (ph *PublicHandler) SearchChunks(
401402
)
402403
}
403404

405+
// Extract KB ID from resource name: namespaces/{namespace}/knowledge-bases/{kb}
406+
kbID := resource.ExtractResourceID(req.GetKnowledgeBase())
404407
logger = logger.With(
405408
zap.String("namespace", namespaceID),
406-
zap.String("knowledge_base", req.GetKnowledgeBaseId()),
409+
zap.String("knowledge_base", kbID),
407410
)
408411

409412
// Get namespace
@@ -417,7 +420,7 @@ func (ph *PublicHandler) SearchChunks(
417420

418421
// Get knowledge base
419422
ownerUID := ns.NsUID
420-
kb, err := ph.service.Repository().GetKnowledgeBaseByOwnerAndKbID(ctx, ownerUID, req.GetKnowledgeBaseId())
423+
kb, err := ph.service.Repository().GetKnowledgeBaseByOwnerAndKbID(ctx, ownerUID, kbID)
421424
if err != nil {
422425
return nil, errorsx.AddMessage(
423426
fmt.Errorf("fetching knowledge base: %w", err),

pkg/handler/converter.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ func convertKBToCatalogPB(kb *repository.KnowledgeBaseModel, ns *resource.Namesp
8484
// Handle optional fields
8585
// Check if ActiveCollectionUID is not zero (nil UUID)
8686
if kb.ActiveCollectionUID.String() != "00000000-0000-0000-0000-000000000000" {
87-
knowledgeBase.ActiveCollectionId = kb.ActiveCollectionUID.String()
87+
knowledgeBase.ActiveCollection = fmt.Sprintf("namespaces/%s/knowledgeBases/%s/collections/%s", namespaceID, kb.ID, kb.ActiveCollectionUID.String())
8888
}
8989

9090
return knowledgeBase
9191
}
9292

9393
// convertKBFileToPB converts database FileModel to protobuf File.
9494
// The `name` field is computed dynamically following other backends' patterns.
95-
func convertKBFileToPB(kbf *repository.FileModel, ns *resource.Namespace, kb *repository.KnowledgeBaseModel, owner *mgmtpb.Owner, creator *mgmtpb.User) *artifactpb.File {
95+
// The objectID parameter is the hash-based object ID (e.g., "obj-abc123") for AIP-122 compliant resource references.
96+
func convertKBFileToPB(kbf *repository.FileModel, ns *resource.Namespace, kb *repository.KnowledgeBaseModel, owner *mgmtpb.Owner, creator *mgmtpb.User, objectID string) *artifactpb.File {
9697
// ownerName is the full namespace reference (e.g., "users/admin" or "organizations/org-id")
9798
ownerName := ns.Name()
9899
// namespaceID is just the ID part (e.g., "admin")
@@ -115,7 +116,7 @@ func convertKBFileToPB(kbf *repository.FileModel, ns *resource.Namespace, kb *re
115116
OwnerName: ownerName,
116117
Owner: owner,
117118
Creator: creator,
118-
KnowledgeBaseIds: []string{kb.ID}, // File associated with this KB
119+
KnowledgeBases: []string{fmt.Sprintf("namespaces/%s/knowledgeBases/%s", namespaceID, kb.ID)}, // File associated with this KB
119120
Size: kbf.Size,
120121
ProcessStatus: convertFileProcessStatus(kbf.ProcessStatus),
121122
Aliases: kbf.Aliases,
@@ -129,13 +130,18 @@ func convertKBFileToPB(kbf *repository.FileModel, ns *resource.Namespace, kb *re
129130
if len(kbf.Tags) > 0 {
130131
file.Tags = kbf.Tags
131132
// Extract collection UIDs from tags with prefix "agent:collection:"
132-
file.CollectionIds = extractCollectionUIDs(kbf.Tags)
133+
file.Collections = extractCollectionUIDs(kbf.Tags)
133134
}
134135

135136
if kbf.ExternalMetadataUnmarshal != nil {
136137
file.ExternalMetadata = kbf.ExternalMetadataUnmarshal
137138
}
138139

140+
// Populate object resource name if file has associated object (AIP-122 compliant)
141+
if objectID != "" {
142+
file.Object = fmt.Sprintf("namespaces/%s/objects/%s", namespaceID, objectID)
143+
}
144+
139145
// Note: TotalChunks and TotalTokens are computed aggregates, not stored directly in the file model
140146
// These would need to be fetched separately if needed
141147

pkg/handler/file.go

Lines changed: 90 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
errorsx "github.com/instill-ai/x/errors"
3131
filetype "github.com/instill-ai/x/file"
3232
logx "github.com/instill-ai/x/log"
33+
"github.com/instill-ai/x/resource"
3334
)
3435

3536
// filterRequestWrapper implements filtering.Request interface to pass a custom filter string
@@ -63,6 +64,16 @@ func parseFileFromName(name string) (namespaceID, fileID string, err error) {
6364
return parts[1], parts[3], nil
6465
}
6566

67+
// parseObjectIDFromResourceName parses an object resource name of format "namespaces/{namespace}/objects/{object_id}"
68+
// and returns the object_id
69+
func parseObjectIDFromResourceName(name string) (objectID string, err error) {
70+
parts := strings.Split(name, "/")
71+
if len(parts) != 4 || parts[0] != "namespaces" || parts[2] != "objects" {
72+
return "", fmt.Errorf("invalid object resource name format, expected namespaces/{namespace}/objects/{object_id}")
73+
}
74+
return parts[3], nil
75+
}
76+
6677
// CreateFile adds a file to a knowledge base (AIP-compliant version of UploadKnowledgeBaseFile).
6778
// It handles file upload, validation, ACL checks, dual processing for staging/rollback KBs,
6879
// and auto-triggers the processing workflow.
@@ -101,8 +112,11 @@ func (ph *PublicHandler) CreateFile(ctx context.Context, req *artifactpb.CreateF
101112
)
102113
}
103114
// ACL - check user's permission to write knowledge base
104-
kbID := req.GetKnowledgeBaseId()
115+
// Parse knowledge_base resource name: namespaces/{namespace}/knowledgeBases/{kb}
116+
kbResourceName := req.GetKnowledgeBase()
117+
kbID := resource.ExtractResourceID(kbResourceName)
105118
logger.Debug("CreateFile: looking up KB",
119+
zap.String("knowledge_base", kbResourceName),
106120
zap.String("knowledge_base_id", kbID),
107121
zap.String("namespace_uid", ns.NsUID.String()),
108122
zap.String("namespace_id", ns.NsID))
@@ -282,13 +296,27 @@ func (ph *PublicHandler) CreateFile(ctx context.Context, req *artifactpb.CreateF
282296

283297
kbFile.CreatorUID = creatorUID
284298
kbFile.StoragePath = destination
299+
// Store the object FK for the new AIP-compliant object reference
300+
objUID := types.ObjectUIDType(objectUID)
301+
kbFile.ObjectUID = &objUID
285302

286303
fileSize, _ := getFileSize(req.File.Content)
287304
kbFile.Size = fileSize
288305
} else {
289-
obj, err := ph.service.Repository().GetObjectByUID(ctx, uuid.FromStringOrNil(req.GetFile().GetObjectUid()))
306+
// Parse object resource name: namespaces/{namespace}/objects/{object_id}
307+
objectResourceName := req.GetFile().GetObject()
308+
objectID, err := parseObjectIDFromResourceName(objectResourceName)
309+
if err != nil {
310+
return nil, errorsx.AddMessage(
311+
fmt.Errorf("parsing object resource name: %w", err),
312+
"Invalid object resource name. Expected format: namespaces/{namespace}/objects/{object_id}",
313+
)
314+
}
315+
316+
// Get object by hash-based ID
317+
obj, err := ph.service.Repository().GetObjectByID(ctx, ns.NsUID, types.ObjectIDType(objectID))
290318
if err != nil {
291-
logger.Error("failed to get knowledge base object with provided UID", zap.Error(err))
319+
logger.Error("failed to get object by ID", zap.Error(err), zap.String("object_id", objectID))
292320
return nil, err
293321
}
294322

@@ -324,6 +352,8 @@ func (ph *PublicHandler) CreateFile(ctx context.Context, req *artifactpb.CreateF
324352
kbFile.CreatorUID = obj.CreatorUID
325353
kbFile.StoragePath = obj.StoragePath
326354
kbFile.Size = obj.Size
355+
// Store the object FK for the new AIP-compliant object reference
356+
kbFile.ObjectUID = &obj.UID
327357

328358
req.File.Type = determineFileType(obj.DisplayName)
329359

@@ -555,14 +585,23 @@ func (ph *PublicHandler) CreateFile(ctx context.Context, req *artifactpb.CreateF
555585
owner, _ := ph.service.FetchOwnerByNamespace(ctx, ns)
556586
creator, _ := ph.service.FetchUserByUID(ctx, res.CreatorUID.String())
557587

588+
// Get object ID for AIP-122 compliant resource name
589+
objectResourceName := ""
590+
if res.ObjectUID != nil {
591+
obj, err := ph.service.Repository().GetObjectByUID(ctx, *res.ObjectUID)
592+
if err == nil && obj != nil {
593+
objectResourceName = fmt.Sprintf("namespaces/%s/objects/%s", namespaceID, obj.ID)
594+
}
595+
}
596+
558597
return &artifactpb.CreateFileResponse{
559598
File: &artifactpb.File{
560599
Id: res.ID,
561600
Slug: res.Slug,
562601
OwnerName: ns.Name(),
563602
Owner: owner,
564603
Creator: creator,
565-
KnowledgeBaseIds: []string{kb.ID}, // Initial KB association
604+
KnowledgeBases: []string{fmt.Sprintf("namespaces/%s/knowledgeBases/%s", namespaceID, kb.ID)}, // Initial KB association
566605
Name: fmt.Sprintf("namespaces/%s/files/%s", namespaceID, res.ID),
567606
DisplayName: res.DisplayName,
568607
Type: req.File.Type,
@@ -573,10 +612,10 @@ func (ph *PublicHandler) CreateFile(ctx context.Context, req *artifactpb.CreateF
573612
TotalChunks: 0,
574613
TotalTokens: 0,
575614
ExternalMetadata: res.PublicExternalMetadataUnmarshal(),
576-
ObjectUid: req.File.ObjectUid,
615+
Object: objectResourceName,
577616
ConvertingPipeline: res.ConvertingPipeline(),
578617
Tags: res.Tags,
579-
CollectionIds: extractCollectionUIDs(res.Tags),
618+
Collections: extractCollectionUIDs(res.Tags),
580619
},
581620
}, nil
582621
}
@@ -906,13 +945,31 @@ func (ph *PublicHandler) ListFiles(ctx context.Context, req *artifactpb.ListFile
906945
knowledgeBaseIDs = fileToKBIDs[kbFile.UID]
907946
}
908947

948+
// Get object ID for AIP-122 compliant resource name
949+
objectID := ""
950+
objectResourceName := ""
951+
if kbFile.ObjectUID != nil {
952+
obj, err := ph.service.Repository().GetObjectByUID(ctx, *kbFile.ObjectUID)
953+
if err == nil && obj != nil {
954+
objectID = string(obj.ID)
955+
objectResourceName = fmt.Sprintf("namespaces/%s/objects/%s", namespaceID, objectID)
956+
}
957+
} else if objectUID != uuid.Nil {
958+
// Fallback: try to get object by UID parsed from storage path
959+
obj, err := ph.service.Repository().GetObjectByUID(ctx, types.ObjectUIDType(objectUID))
960+
if err == nil && obj != nil {
961+
objectID = string(obj.ID)
962+
objectResourceName = fmt.Sprintf("namespaces/%s/objects/%s", namespaceID, objectID)
963+
}
964+
}
965+
909966
file := &artifactpb.File{
910967
Id: fileID,
911968
Slug: kbFile.Slug,
912969
OwnerName: ns.Name(),
913970
Owner: owner,
914971
Creator: creator,
915-
KnowledgeBaseIds: knowledgeBaseIDs,
972+
KnowledgeBases: knowledgeBaseIDs,
916973
Name: fmt.Sprintf("namespaces/%s/files/%s", namespaceID, fileID),
917974
DisplayName: kbFile.DisplayName,
918975
Type: artifactpb.File_Type(artifactpb.File_Type_value[kbFile.FileType]),
@@ -923,11 +980,11 @@ func (ph *PublicHandler) ListFiles(ctx context.Context, req *artifactpb.ListFile
923980
ExternalMetadata: kbFile.PublicExternalMetadataUnmarshal(),
924981
TotalChunks: int32(totalChunks[kbFile.UID]),
925982
TotalTokens: int32(totalTokens[kbFile.UID]),
926-
ObjectUid: objectUID.String(),
983+
Object: objectResourceName,
927984
DownloadUrl: downloadURL,
928985
ConvertingPipeline: kbFile.ConvertingPipeline(),
929986
Tags: []string(kbFile.Tags),
930-
CollectionIds: extractCollectionUIDs(kbFile.Tags),
987+
Collections: extractCollectionUIDs(kbFile.Tags),
931988
}
932989

933990
// Include status message (error or success message)
@@ -1478,7 +1535,7 @@ func (ph *PublicHandler) DeleteFile(ctx context.Context, req *artifactpb.DeleteF
14781535
logger, _ := logx.GetZapLogger(ctx)
14791536

14801537
// Parse resource name to get namespace_id and file_id
1481-
_, fileID, err := parseFileFromName(req.GetName())
1538+
namespaceID, fileID, err := parseFileFromName(req.GetName())
14821539
if err != nil {
14831540
return nil, errorsx.AddMessage(
14841541
fmt.Errorf("parsing file name: %w", err),
@@ -1772,7 +1829,7 @@ func (ph *PublicHandler) DeleteFile(ctx context.Context, req *artifactpb.DeleteF
17721829
}
17731830

17741831
return &artifactpb.DeleteFileResponse{
1775-
FileId: fUID.String(),
1832+
Name: fmt.Sprintf("namespaces/%s/files/%s", namespaceID, fUID.String()),
17761833
}, nil
17771834

17781835
}
@@ -1952,8 +2009,17 @@ func (ph *PublicHandler) UpdateFile(ctx context.Context, req *artifactpb.UpdateF
19522009
owner, _ := ph.service.FetchOwnerByNamespace(ctx, ns)
19532010
creator, _ := ph.service.FetchUserByUID(ctx, updatedFile.CreatorUID.String())
19542011

2012+
// Get object ID if file has an associated object (for AIP-122 compliant resource reference)
2013+
objectID := ""
2014+
if updatedFile.ObjectUID != nil {
2015+
obj, err := ph.service.Repository().GetObjectByUID(ctx, *updatedFile.ObjectUID)
2016+
if err == nil && obj != nil {
2017+
objectID = string(obj.ID)
2018+
}
2019+
}
2020+
19552021
// Convert to protobuf
1956-
pbFile := convertKBFileToPB(updatedFile, ns, kb, owner, creator)
2022+
pbFile := convertKBFileToPB(updatedFile, ns, kb, owner, creator, objectID)
19572023

19582024
return &artifactpb.UpdateFileResponse{
19592025
File: pbFile,
@@ -2117,8 +2183,17 @@ func (ph *PublicHandler) ReprocessFile(ctx context.Context, req *artifactpb.Repr
21172183
owner, _ := ph.service.FetchOwnerByNamespace(ctx, ns)
21182184
creator, _ := ph.service.FetchUserByUID(ctx, updatedFile.CreatorUID.String())
21192185

2186+
// Get object ID if file has an associated object (for AIP-122 compliant resource reference)
2187+
objectID := ""
2188+
if updatedFile.ObjectUID != nil {
2189+
obj, err := ph.service.Repository().GetObjectByUID(ctx, *updatedFile.ObjectUID)
2190+
if err == nil && obj != nil {
2191+
objectID = string(obj.ID)
2192+
}
2193+
}
2194+
21202195
// Convert to protobuf response with updated file status
2121-
pbFile := convertKBFileToPB(&updatedFile, ns, kb, owner, creator)
2196+
pbFile := convertKBFileToPB(&updatedFile, ns, kb, owner, creator, objectID)
21222197

21232198
return &artifactpb.ReprocessFileResponse{
21242199
File: pbFile,
@@ -2261,13 +2336,13 @@ func getPositionUnit(fileType artifactpb.File_Type) artifactpb.File_Position_Uni
22612336
return artifactpb.File_Position_UNIT_UNSPECIFIED
22622337
}
22632338

2264-
// Check if objectUID is provided, and all other required fields if not
2339+
// Check if object is provided, and all other required fields if not
22652340
func checkUploadKnowledgeBaseFileRequest(req *artifactpb.CreateFileRequest) (hasObject bool, _ error) {
22662341
if req.GetParent() == "" {
22672342
return false, fmt.Errorf("%w: parent is required", errorsx.ErrInvalidArgument)
22682343
}
22692344

2270-
if req.GetFile().GetObjectUid() == "" {
2345+
if req.GetFile().GetObject() == "" {
22712346
// File upload doesn't reference object, so request must contain the
22722347
// file contents.
22732348
if req.GetFile().GetDisplayName() == "" {

0 commit comments

Comments
 (0)