@@ -22,7 +22,9 @@ import (
2222 "reflect"
2323
2424 "github.com/arduino/arduino-cli/commands/cmderrors"
25+ f "github.com/arduino/arduino-cli/internal/algorithms"
2526 "github.com/arduino/arduino-cli/internal/cli/configuration"
27+ "github.com/arduino/arduino-cli/internal/go-configmap"
2628 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2729 "google.golang.org/protobuf/proto"
2830 "gopkg.in/yaml.v3"
@@ -187,23 +189,29 @@ func (s *arduinoCoreServerImpl) ConfigurationSave(ctx context.Context, req *rpc.
187189
188190// SettingsReadFromFile read settings from a YAML file and replace the settings currently stored in memory.
189191func (s * arduinoCoreServerImpl ) ConfigurationOpen (ctx context.Context , req * rpc.ConfigurationOpenRequest ) (* rpc.ConfigurationOpenResponse , error ) {
192+ warnings := []string {}
193+
190194 switch req .GetSettingsFormat () {
191195 case "yaml" :
192196 err := yaml .Unmarshal ([]byte (req .GetEncodedSettings ()), s .settings )
193- if err != nil {
197+ if errs , ok := err .(* configmap.UnmarshalErrors ); ok {
198+ warnings = f .Map (errs .WrappedErrors (), (error ).Error )
199+ } else if err != nil {
194200 return nil , fmt .Errorf ("error unmarshalling settings: %v" , err )
195201 }
196202 case "json" :
197203 err := json .Unmarshal ([]byte (req .GetEncodedSettings ()), s .settings )
198- if err != nil {
204+ if errs , ok := err .(* configmap.UnmarshalErrors ); ok {
205+ warnings = f .Map (errs .WrappedErrors (), (error ).Error )
206+ } else if err != nil {
199207 return nil , fmt .Errorf ("error unmarshalling settings: %v" , err )
200208 }
201209 default :
202210 return nil , & cmderrors.InvalidArgumentError {Message : fmt .Sprintf ("unsupported format: %s" , req .GetSettingsFormat ())}
203211 }
204212
205213 configuration .InjectEnvVars (s .settings )
206- return & rpc.ConfigurationOpenResponse {}, nil
214+ return & rpc.ConfigurationOpenResponse {Warnings : warnings }, nil
207215}
208216
209217// SettingsEnumerate returns the list of all the settings keys.
0 commit comments