diff --git a/pkg/capabilities/consensus/ocr3/capability_test.go b/pkg/capabilities/consensus/ocr3/capability_test.go index e383a487c..627e67dd4 100644 --- a/pkg/capabilities/consensus/ocr3/capability_test.go +++ b/pkg/capabilities/consensus/ocr3/capability_test.go @@ -325,6 +325,7 @@ func TestOCR3Capability_ValidateConfig(t *testing.T) { "encoder": "", "encoder_config": map[string]any{}, "report_id": "aaaa", + "key_id": "key_id", }) require.NoError(t, err) @@ -337,6 +338,7 @@ func TestOCR3Capability_ValidateConfig(t *testing.T) { config, err := values.NewMap(map[string]any{ "aggregation_method": "data_feeds", "report_id": "aaaa", + "key_id": "key_id", }) require.NoError(t, err) @@ -353,6 +355,7 @@ func TestOCR3Capability_ValidateConfig(t *testing.T) { "encoder": "", "encoder_config": map[string]any{}, "report_id": "aa", + "key_id": "key_id", }) require.NoError(t, err) @@ -361,6 +364,22 @@ func TestOCR3Capability_ValidateConfig(t *testing.T) { assert.Contains(t, err.Error(), "does not match pattern") // taken from the error json schema error message require.Nil(t, c) }) + + t.Run("InvalidConfig no key_id", func(t *testing.T) { + config, err := values.NewMap(map[string]any{ + "aggregation_method": "data_feeds", + "aggregation_config": map[string]any{}, + "encoder": "", + "encoder_config": map[string]any{}, + "report_id": "aaaa", + }) + require.NoError(t, err) + + c, err := o.ValidateConfig(config) + require.Error(t, err) + assert.Contains(t, err.Error(), "missing properties: 'key_id'") // taken from the error json schema error message + require.Nil(t, c) + }) } func TestOCR3Capability_RespondsToLateRequest(t *testing.T) { diff --git a/pkg/capabilities/consensus/ocr3/models.go b/pkg/capabilities/consensus/ocr3/models.go index 86662dc31..81cd1e13a 100644 --- a/pkg/capabilities/consensus/ocr3/models.go +++ b/pkg/capabilities/consensus/ocr3/models.go @@ -12,7 +12,7 @@ type config struct { ReportID string `mapstructure:"report_id" json:"report_id" jsonschema:"required,pattern=^[a-f0-9]{4}$"` RequestTimeoutMS int64 `mapstructure:"request_timeout_ms" json:"request_timeout_ms"` - KeyID string `mapstructure:"key_id" json:"key_id"` + KeyID string `mapstructure:"key_id" json:"key_id,omitempty" jsonschema:"required"` } type inputs struct {