Skip to content

Fix workflow list MongoDB fallback#1608

Merged
JoshVanL merged 5 commits intodapr:masterfrom
JoshVanL:mongodb-wf-list-fix
Apr 6, 2026
Merged

Fix workflow list MongoDB fallback#1608
JoshVanL merged 5 commits intodapr:masterfrom
JoshVanL:mongodb-wf-list-fix

Conversation

@JoshVanL
Copy link
Copy Markdown
Contributor

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.

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>
Copilot AI review requested due to automatic review settings March 13, 2026 00:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _id and 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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _id rather than key.
  • Decode _id values into the returned key list.
  • Add unit tests validating _id usage, 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.

acroca
acroca previously approved these changes Mar 13, 2026
cicoyle
cicoyle previously approved these changes Mar 31, 2026
Copy link
Copy Markdown
Contributor

@cicoyle cicoyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but plz address copilots feedback

@JoshVanL JoshVanL dismissed stale reviews from acroca and cicoyle via 3182d68 April 6, 2026 19:45
@JoshVanL
Copy link
Copy Markdown
Contributor Author

JoshVanL commented Apr 6, 2026

@cicoyle addressed comments!

@JoshVanL JoshVanL merged commit 2d53a10 into dapr:master Apr 6, 2026
34 of 37 checks passed
dapr-bot pushed a commit that referenced this pull request Apr 6, 2026
* 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>
JoshVanL added a commit that referenced this pull request Apr 7, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants