From 440f25ad472b224fff175cbe1acab8d7d707fa3b Mon Sep 17 00:00:00 2001 From: krehermann Date: Fri, 7 Jun 2024 13:19:00 -0600 Subject: [PATCH] KS-311: allow 0x prefixed wf owner (#13469) --- core/services/job/models.go | 1 + core/services/job/models_test.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/services/job/models.go b/core/services/job/models.go index e1f1e652f53..5c7795a32f6 100644 --- a/core/services/job/models.go +++ b/core/services/job/models.go @@ -878,6 +878,7 @@ func (w *WorkflowSpec) Validate() error { return fmt.Errorf("%w: incorrect length for id %s: expected %d, got %d", ErrInvalidWorkflowID, w.WorkflowID, workflowIDLen, len(w.WorkflowID)) } + w.WorkflowOwner = strings.TrimPrefix(w.WorkflowOwner, "0x") _, err := hex.DecodeString(w.WorkflowOwner) if err != nil { return fmt.Errorf("%w: expected hex encoding got %s: %w", ErrInvalidWorkflowOwner, w.WorkflowOwner, err) diff --git a/core/services/job/models_test.go b/core/services/job/models_test.go index 39ac0f83c1f..a5dc12bcbc6 100644 --- a/core/services/job/models_test.go +++ b/core/services/job/models_test.go @@ -294,7 +294,14 @@ func TestWorkflowSpec_Validate(t *testing.T) { WorkflowName: "ten bytes!", }, }, - + { + name: "valid 0x prefix hex owner", + fields: fields{ + WorkflowID: "15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef", + WorkflowOwner: "0x00000000000000000000000000000000000000ff", + WorkflowName: "ten bytes!", + }, + }, { name: "not hex owner", fields: fields{ @@ -304,7 +311,6 @@ func TestWorkflowSpec_Validate(t *testing.T) { }, expectedErr: ErrInvalidWorkflowOwner, }, - { name: "not len 40 owner", fields: fields{ @@ -314,7 +320,6 @@ func TestWorkflowSpec_Validate(t *testing.T) { }, expectedErr: ErrInvalidWorkflowOwner, }, - { name: "not len 10 name", fields: fields{