Conversation
The CLI's direct MongoDB fallback (used when gRPC ListInstanceIDs is unavailable) searched for a "key" field, but the Dapr MongoDB state store stores document keys in the "_id" field. This caused `dapr workflow list -c 'mongodb://...'` to always return empty results. Signed-off-by: joshvanl <me@joshvanl.dev>
There was a problem hiding this comment.
Pull request overview
Fixes the CLI’s MongoDB direct-query fallback used for dapr workflow list by querying workflow metadata keys from MongoDB’s _id field (as stored by the Dapr MongoDB state store), instead of a non-existent key field.
Changes:
- Update MongoDB filter to query on
_idand decode keys from_id. - Adjust MongoDB projection to return
_id. - Add unit tests validating
_id-based behavior and the generated query filter.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/workflow/db/mongo.go | Switches MongoDB list query from key to _id and updates projection/decoding accordingly. |
| pkg/workflow/db/mongo_test.go | Adds mocked MongoDB tests for listing and filter construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: joshvanl <me@joshvanl.dev>
There was a problem hiding this comment.
Pull request overview
Fixes the CLI’s MongoDB direct-access fallback for workflow listing by querying the correct MongoDB document key field (_id) used by the Dapr MongoDB state store, preventing empty results when gRPC ListInstanceIDs is unavailable.
Changes:
- Update MongoDB list query to filter/project on
_idrather thankey. - Decode
_idvalues into the returned key list. - Add unit tests validating
_idusage, regex filter construction, and empty-result behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/workflow/db/mongo.go | Switches Mongo query filter/projection and decode tag from key to _id. |
| pkg/workflow/db/mongo_test.go | Adds mock-based tests ensuring _id is used and regex is formed correctly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| mt.AddMockResponses(mtest.CreateCursorResponse(1, "daprStore.daprCollection", mtest.FirstBatch, | ||
| bson.D{{Key: "_id", Value: key1}}, | ||
| ), mtest.CreateCursorResponse(0, "daprStore.daprCollection", mtest.NextBatch, | ||
| bson.D{{Key: "_id", Value: key2}}, | ||
| )) |
| mt.AddMockResponses(mtest.CreateCursorResponse(0, "daprStore.daprCollection", mtest.FirstBatch)) | ||
|
|
| mt.AddMockResponses(mtest.CreateCursorResponse(0, "daprStore.daprCollection", mtest.FirstBatch)) | ||
|
|
The CLI's direct MongoDB fallback (used when gRPC ListInstanceIDs is unavailable) searched for a "key" field, but the Dapr MongoDB state store stores document keys in the "_id" field. This caused
dapr workflow list -c 'mongodb://...'to always return empty results.