Skip to content

Commit 7b87951

Browse files
authored
Fix identity types (dbos-inc#138)
- Fix `AuthenticatedUser` and `AssumedRole` to use strings: we can distinguish whether they are set by checking zero values. - Fix `AuthenticatedRoles` to be a slice of string. - Fix protocol to marshal `AuthenticatedRoles` to JSON if set.
1 parent 0bf8120 commit 7b87951

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

dbos/conductor_protocol.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,16 @@ func formatListWorkflowsResponseBody(wf WorkflowStatus) listWorkflowsConductorRe
115115
}
116116

117117
// Copy optional fields
118-
output.AuthenticatedUser = wf.AuthenticatedUser
119-
output.AssumedRole = wf.AssumedRole
120-
output.AuthenticatedRoles = wf.AuthenticatedRoles
118+
output.AuthenticatedUser = &wf.AuthenticatedUser
119+
output.AssumedRole = &wf.AssumedRole
120+
// Convert authenticated roles to JSON string if present
121+
if len(wf.AuthenticatedRoles) > 0 {
122+
rolesJSON, err := json.Marshal(wf.AuthenticatedRoles)
123+
if err == nil {
124+
rolesStr := string(rolesJSON)
125+
output.AuthenticatedRoles = &rolesStr
126+
}
127+
}
121128

122129
// Convert input/output to JSON strings if present
123130
if wf.Input != nil {

dbos/workflow.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ type WorkflowStatus struct {
3535
ID string `json:"workflow_uuid"` // Unique identifier for the workflow
3636
Status WorkflowStatusType `json:"status"` // Current execution status
3737
Name string `json:"name"` // Function name of the workflow
38-
AuthenticatedUser *string `json:"authenticated_user,omitempty"` // User who initiated the workflow (if applicable)
39-
AssumedRole *string `json:"assumed_role,omitempty"` // Role assumed during execution (if applicable)
40-
AuthenticatedRoles *string `json:"authenticated_roles,omitempty"` // Roles available to the user (if applicable)
38+
AuthenticatedUser string `json:"authenticated_user,omitempty"` // User who initiated the workflow (if applicable)
39+
AssumedRole string `json:"assumed_role,omitempty"` // Role assumed during execution (if applicable)
40+
AuthenticatedRoles []string `json:"authenticated_roles,omitempty"` // Roles available to the user (if applicable)
4141
Output any `json:"output,omitempty"` // Workflow output (available after completion)
4242
Error error `json:"error,omitempty"` // Error information (if status is ERROR)
4343
ExecutorID string `json:"executor_id"` // ID of the executor running this workflow

0 commit comments

Comments
 (0)