Skip to content

Commit

Permalink
clarify error messages around reading sinkconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Nov 6, 2023
1 parent 627bf91 commit 6a27a60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifest/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func (r *Reader) newPkgFromManifest(manif *Manifest) (*pbsubstreams.Package, err
converter := newManifestConverter(r.currentInput, r.skipSourceCodeImportValidation)
pkg, descriptors, dynMessage, err := converter.Convert(manif)
if err != nil {
return nil, fmt.Errorf("unable to convert manifest to package: %w", err)
return nil, err
}
r.sinkConfigDynamicMessage = dynMessage

Expand Down
8 changes: 4 additions & 4 deletions manifest/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ func (r *manifestConverter) loadSinkConfig(pkg *pbssv1.Package, m *Manifest) err

jsonConfig, err := convertYAMLtoJSONCompat(m.Sink.Config, m.resolvePath, "", fieldResolver(msgDesc))
if err != nil {
return fmt.Errorf("sink: config: converting to json: %w", err)
return fmt.Errorf("converting YAML to JSON: %w", err)
}
jsonConfigBytes, err := json.Marshal(jsonConfig)
if err != nil {
return fmt.Errorf("sink: config: error marshalling to json: %w", err)
return fmt.Errorf("marshalling config to JSON: %w", err)
}

dynConf := dynamic.NewMessageFactoryWithDefaults().NewDynamicMessage(msgDesc)
if err := dynConf.UnmarshalJSON(jsonConfigBytes); err != nil {
return fmt.Errorf("sink: config: encoding json into protobuf message: %w", err)
return fmt.Errorf("cannot unmarshal the SinkConfig into type %s. Is your YAML file valid ? %w", m.Sink.Type, err)
}
r.sinkConfigDynamicMessage = dynConf
pbBytes, err := dynConf.Marshal()
if err != nil {
return fmt.Errorf("sink: config: encoding protobuf from dynamic message: %w", err)
return fmt.Errorf("encoding protobuf from dynamic message: %w", err)
}
pkg.SinkConfig = &anypb.Any{
TypeUrl: m.Sink.Type,
Expand Down

0 comments on commit 6a27a60

Please sign in to comment.