Skip to content

Commit

Permalink
KS-311: allow 0x prefixed wf owner (#13469)
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann authored Jun 7, 2024
1 parent c318583 commit 440f25a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/services/job/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions core/services/job/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -304,7 +311,6 @@ func TestWorkflowSpec_Validate(t *testing.T) {
},
expectedErr: ErrInvalidWorkflowOwner,
},

{
name: "not len 40 owner",
fields: fields{
Expand All @@ -314,7 +320,6 @@ func TestWorkflowSpec_Validate(t *testing.T) {
},
expectedErr: ErrInvalidWorkflowOwner,
},

{
name: "not len 10 name",
fields: fields{
Expand Down

0 comments on commit 440f25a

Please sign in to comment.