Fix workflow list MongoDB fallback#1608
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.
cicoyle
left a comment
There was a problem hiding this comment.
lgtm, but plz address copilots feedback
Signed-off-by: joshvanl <me@joshvanl.dev>
|
@cicoyle addressed comments! |
* Fix workflow list MongoDB fallback 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> * Review comments Signed-off-by: joshvanl <me@joshvanl.dev> * Review comments Signed-off-by: joshvanl <me@joshvanl.dev> --------- Signed-off-by: joshvanl <me@joshvanl.dev> (cherry picked from commit 2d53a10) Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com>
* Fix workflow list MongoDB fallback (#1608) * Fix workflow list MongoDB fallback 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> * Review comments Signed-off-by: joshvanl <me@joshvanl.dev> * Review comments Signed-off-by: joshvanl <me@joshvanl.dev> --------- Signed-off-by: joshvanl <me@joshvanl.dev> (cherry picked from commit 2d53a10) Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com> * Fix version test race condition Signed-off-by: joshvanl <me@joshvanl.dev> --------- Signed-off-by: joshvanl <me@joshvanl.dev> Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com> Co-authored-by: Josh van Leeuwen <me@joshvanl.dev>
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.