Skip to content

Commit 24397b3

Browse files
committed
incoming list wf requests give strings for status
1 parent bb4ed69 commit 24397b3

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

dbos/admin_server.go

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ const (
3333

3434
// listWorkflowsRequest represents the request structure for listing workflows
3535
type listWorkflowsRequest struct {
36-
WorkflowUUIDs []string `json:"workflow_uuids"` // Filter by specific workflow IDs
37-
AuthenticatedUser *string `json:"authenticated_user"` // Filter by user who initiated the workflow
38-
StartTime *time.Time `json:"start_time"` // Filter workflows created after this time (RFC3339 format)
39-
EndTime *time.Time `json:"end_time"` // Filter workflows created before this time (RFC3339 format)
40-
Status []WorkflowStatusType `json:"status"` // Filter by workflow status(es)
41-
ApplicationVersion *string `json:"application_version"` // Filter by application version
42-
WorkflowName *string `json:"workflow_name"` // Filter by workflow function name
43-
Limit *int `json:"limit"` // Maximum number of results to return
44-
Offset *int `json:"offset"` // Offset for pagination
45-
SortDesc *bool `json:"sort_desc"` // Sort in descending order by creation time
46-
WorkflowIDPrefix *string `json:"workflow_id_prefix"` // Filter by workflow ID prefix
47-
LoadInput *bool `json:"load_input"` // Include workflow input in response
48-
LoadOutput *bool `json:"load_output"` // Include workflow output in response
49-
QueueName *string `json:"queue_name"` // Filter by queue name (for queued workflows)
36+
WorkflowUUIDs []string `json:"workflow_uuids"` // Filter by specific workflow IDs
37+
AuthenticatedUser *string `json:"authenticated_user"` // Filter by user who initiated the workflow
38+
StartTime *time.Time `json:"start_time"` // Filter workflows created after this time (RFC3339 format)
39+
EndTime *time.Time `json:"end_time"` // Filter workflows created before this time (RFC3339 format)
40+
Status []string `json:"status"` // Filter by workflow status(es)
41+
ApplicationVersion *string `json:"application_version"` // Filter by application version
42+
WorkflowName *string `json:"workflow_name"` // Filter by workflow function name
43+
Limit *int `json:"limit"` // Maximum number of results to return
44+
Offset *int `json:"offset"` // Offset for pagination
45+
SortDesc *bool `json:"sort_desc"` // Sort in descending order by creation time
46+
WorkflowIDPrefix *string `json:"workflow_id_prefix"` // Filter by workflow ID prefix
47+
LoadInput *bool `json:"load_input"` // Include workflow input in response
48+
LoadOutput *bool `json:"load_output"` // Include workflow output in response
49+
QueueName *string `json:"queue_name"` // Filter by queue name (for queued workflows)
5050
}
5151

5252
// buildOptions converts the request struct into a slice of ListWorkflowsOption
@@ -65,7 +65,11 @@ func (req *listWorkflowsRequest) toListWorkflowsOptions() []ListWorkflowsOption
6565
opts = append(opts, WithEndTime(*req.EndTime))
6666
}
6767
if len(req.Status) > 0 {
68-
opts = append(opts, WithStatus(req.Status))
68+
statuses := make([]WorkflowStatusType, len(req.Status))
69+
for i, s := range req.Status {
70+
statuses[i] = WorkflowStatusType(s)
71+
}
72+
opts = append(opts, WithStatus(statuses))
6973
}
7074
if req.ApplicationVersion != nil {
7175
opts = append(opts, WithAppVersion(*req.ApplicationVersion))

dbos/admin_server_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,37 @@ func TestAdminServer(t *testing.T) {
160160
// This will be overridden in the test
161161
},
162162
},
163+
{
164+
name: "Workflows endpoint accepts all filters without error",
165+
method: "POST",
166+
endpoint: fmt.Sprintf("http://localhost:3001/%s", strings.TrimPrefix(_WORKFLOWS_PATTERN, "POST /")),
167+
body: bytes.NewBuffer(mustMarshal(map[string]any{
168+
"workflow_uuids": []string{"test-id-1", "test-id-2"},
169+
"authenticated_user": "test-user",
170+
"start_time": time.Now().Add(-24 * time.Hour).Format(time.RFC3339),
171+
"end_time": time.Now().Format(time.RFC3339),
172+
"status": []string{"PENDING", "SUCCESS"},
173+
"application_version": "v1.0.0",
174+
"workflow_name": "testWorkflow",
175+
"limit": 100,
176+
"offset": 0,
177+
"sort_desc": true,
178+
"workflow_id_prefix": "test-",
179+
"load_input": true,
180+
"load_output": true,
181+
"queue_name": "test-queue",
182+
})),
183+
contentType: "application/json",
184+
expectedStatus: http.StatusOK,
185+
validateResp: func(t *testing.T, resp *http.Response) {
186+
var workflows []map[string]any
187+
err := json.NewDecoder(resp.Body).Decode(&workflows)
188+
require.NoError(t, err, "Failed to decode workflows response")
189+
// We expect an empty array since these filters likely won't match any workflows
190+
assert.NotNil(t, workflows, "Expected non-nil workflows array")
191+
// No error is success - the result can be empty
192+
},
193+
},
163194
}
164195

165196
for _, tt := range tests {

0 commit comments

Comments
 (0)