Skip to content

Commit da6418f

Browse files
committed
fix(fanout): keep string value in fanout proto, skip binary content
Revert fanout proto value field to string since plugins expect text. Guard the assignment with UTF-8 validation so binary inline content is only available via the Content bytes field. Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent 4b5f781 commit da6418f

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

app/controlplane/plugins/sdk/v1/plugin/api/fanout.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/plugins/sdk/v1/plugin/api/fanout.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ message ExecuteRequest {
109109
bytes content = 1;
110110
string name = 2;
111111
string type = 3;
112-
bytes value = 4;
112+
string value = 4;
113113
string hash = 5;
114114
bool uploaded_to_cas = 6;
115115
string file_name = 7;

app/controlplane/plugins/sdk/v1/plugin/api/translation.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2023-2026 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@ package api
1717

1818
import (
1919
"errors"
20+
"unicode/utf8"
2021

2122
"github.com/chainloop-dev/chainloop/app/controlplane/plugins/sdk/v1"
2223
"github.com/chainloop-dev/chainloop/pkg/attestation/renderer/chainloop"
@@ -148,11 +149,18 @@ func MetadataProtoToSDK(in *ExecuteRequest_Metadata) *sdk.ChainloopMetadata {
148149
}
149150

150151
func MaterialSDKToProto(in *sdk.ExecuteMaterial) *ExecuteRequest_NormalizedMaterial {
152+
// The fanout proto uses string for value since plugins expect text.
153+
// Binary inline content is available in the Content bytes field instead.
154+
var value string
155+
if utf8.Valid(in.Value) {
156+
value = string(in.Value)
157+
}
158+
151159
return &ExecuteRequest_NormalizedMaterial{
152160
Content: in.Content,
153161
Name: in.Name,
154162
Type: in.Type,
155-
Value: in.Value,
163+
Value: value,
156164
FileName: in.Filename,
157165
Hash: in.Hash.String(),
158166
UploadedToCas: in.UploadedToCAS,
@@ -171,7 +179,7 @@ func MaterialProtoToSDK(in *ExecuteRequest_NormalizedMaterial) *sdk.ExecuteMater
171179
NormalizedMaterial: &chainloop.NormalizedMaterial{
172180
Name: in.Name,
173181
Type: in.Type,
174-
Value: in.Value,
182+
Value: []byte(in.Value),
175183
Filename: in.FileName,
176184
UploadedToCAS: in.UploadedToCas,
177185
Hash: &hash,

buf.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ modules:
102102
except:
103103
- EXTENSION_NO_DELETE
104104
- FIELD_SAME_DEFAULT
105-
ignore_only:
106-
# string→bytes is wire-compatible; internal plugin SDK, not public API
107-
FIELD_SAME_TYPE:
108-
- app/controlplane/plugins/sdk/v1/plugin/api/fanout.proto
109105
- path: pkg/attestation/crafter/api
110106
lint:
111107
use:

0 commit comments

Comments
 (0)