@@ -3,6 +3,7 @@ package dbos
33import (
44 "context"
55 _ "embed"
6+ "encoding/json"
67 "errors"
78 "fmt"
89 "io"
@@ -485,14 +486,22 @@ func (s *sysDB) insertWorkflowStatus(ctx context.Context, input insertWorkflowSt
485486 var result insertWorkflowResult
486487 var timeoutMSResult * int64
487488 var workflowDeadlineEpochMS * int64
489+
490+ // Marshal authenticated roles (slice of strings) to JSON for TEXT column
491+ authenticatedRoles , err := json .Marshal (input .status .AuthenticatedRoles )
492+
493+ if err != nil {
494+ return nil , fmt .Errorf ("failed to marshal the authenticated roles: %w" , err )
495+ }
496+
488497 err = input .tx .QueryRow (ctx , query ,
489498 input .status .ID ,
490499 input .status .Status ,
491500 input .status .Name ,
492501 input .status .QueueName ,
493502 input .status .AuthenticatedUser ,
494503 input .status .AssumedRole ,
495- input . status . AuthenticatedRoles ,
504+ authenticatedRoles ,
496505 input .status .ExecutorID ,
497506 applicationVersion ,
498507 input .status .ApplicationID ,
@@ -705,11 +714,12 @@ func (s *sysDB) listWorkflows(ctx context.Context, input listWorkflowsDBInput) (
705714 var deduplicationID * string
706715 var applicationVersion * string
707716 var executorID * string
717+ var authenticatedRoles * string
708718
709719 // Build scan arguments dynamically based on loaded columns
710720 scanArgs := []any {
711721 & wf .ID , & wf .Status , & wf .Name , & wf .AuthenticatedUser , & wf .AssumedRole ,
712- & wf . AuthenticatedRoles , & executorID , & createdAtMs ,
722+ & authenticatedRoles , & executorID , & createdAtMs ,
713723 & updatedAtMs , & applicationVersion , & wf .ApplicationID ,
714724 & wf .Attempts , & queueName , & timeoutMs ,
715725 & deadlineMs , & startedAtMs , & deduplicationID , & wf .Priority ,
@@ -727,6 +737,12 @@ func (s *sysDB) listWorkflows(ctx context.Context, input listWorkflowsDBInput) (
727737 return nil , fmt .Errorf ("failed to scan workflow row: %w" , err )
728738 }
729739
740+ if authenticatedRoles != nil && * authenticatedRoles != "" {
741+ if err := json .Unmarshal ([]byte (* authenticatedRoles ), & wf .AuthenticatedRoles ); err != nil {
742+ return nil , fmt .Errorf ("failed to unmarshal authenticated_roles: %w" , err )
743+ }
744+ }
745+
730746 if queueName != nil && len (* queueName ) > 0 {
731747 wf .QueueName = * queueName
732748 }
@@ -1088,13 +1104,20 @@ func (s *sysDB) forkWorkflow(ctx context.Context, input forkWorkflowDBInput) (st
10881104 return "" , fmt .Errorf ("failed to serialize input: %w" , err )
10891105 }
10901106
1107+ // Marshal authenticated roles (slice of strings) to JSON for TEXT column
1108+ authenticatedRoles , err := json .Marshal (originalWorkflow .AuthenticatedRoles )
1109+
1110+ if err != nil {
1111+ return "" , fmt .Errorf ("failed to marshal the authenticated roles: %w" , err )
1112+ }
1113+
10911114 _ , err = tx .Exec (ctx , insertQuery ,
10921115 forkedWorkflowID ,
10931116 WorkflowStatusEnqueued ,
10941117 originalWorkflow .Name ,
10951118 originalWorkflow .AuthenticatedUser ,
10961119 originalWorkflow .AssumedRole ,
1097- originalWorkflow . AuthenticatedRoles ,
1120+ authenticatedRoles ,
10981121 & appVersion ,
10991122 originalWorkflow .ApplicationID ,
11001123 _DBOS_INTERNAL_QUEUE_NAME ,
0 commit comments