Skip to content

Add instance ID prefix orchestration queries - #251

Open
andystaples wants to merge 3 commits into
mainfrom
andystaples-query-instance-prefix
Open

Add instance ID prefix orchestration queries#251
andystaples wants to merge 3 commits into
mainfrom
andystaples-query-instance-prefix

Conversation

@andystaples

Copy link
Copy Markdown
Contributor

Summary

  • add instance_id_prefix to OrchestrationQuery and serialize it to InstanceQuery.instanceIdPrefix
  • cover protobuf serialization and in-memory query filtering
  • document the public query filter

Validation

  • python -m pytest tests/durabletask/test_batch_actions.py
  • python -m flake8 durabletask
  • python -m flake8 tests/durabletask

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: abe44a4b-db94-4661-bb3b-2d7dd30b1e78
Copilot AI lite review requested due to automatic review settings August 10, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new public query filter to the core SDK to allow querying orchestrations by an instance ID prefix, wiring it through gRPC request serialization and validating behavior via tests and changelog documentation.

Changes:

  • Added OrchestrationQuery.instance_id_prefix as a public filter option.
  • Serialized the new filter to InstanceQuery.instanceIdPrefix in build_query_instances_req.
  • Added tests for serialization and in-memory backend filtering; documented the new API in CHANGELOG.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/durabletask/test_batch_actions.py Adds orchestration query-by-prefix test and serialization regression test.
durabletask/internal/client_helpers.py Populates InstanceQuery.instanceIdPrefix from OrchestrationQuery.instance_id_prefix.
durabletask/client.py Extends the public OrchestrationQuery dataclass with instance_id_prefix.
CHANGELOG.md Documents the new user-facing query filter under ## Unreleased.
Suppressed comments (1)

durabletask/client.py:199

  • OrchestrationQuery is a public dataclass; inserting instance_id_prefix in the middle changes the positional argument order, which can break callers that instantiate OrchestrationQuery positionally. To preserve backwards compatibility, append new fields at the end of the dataclass field list.
    instance_id_prefix: str | None = None
    # Some backends don't respond well with max_instance_count = None, so we use the integer limit for non-paginated
    # results instead.
    max_instance_count: int | None = (1 << 31) - 1
    fetch_inputs_and_outputs: bool = False

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@berndverst Bernd Verst (berndverst) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Requesting changes for the positional-constructor compatibility regression. The wire mapping and query behavior otherwise look sound.

Comment thread durabletask/client.py Outdated
created_time_from: datetime | None = None
created_time_to: datetime | None = None
runtime_status: list[OrchestrationStatus] | None = None
instance_id_prefix: str | None = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This inserts a field into the middle of a public dataclass's generated positional constructor. Existing OrchestrationQuery(None, None, None, None, True) calls now bind True to max_instance_count and leave fetch_inputs_and_outputs=False; numeric fourth arguments can reach StringValue as the prefix and raise TypeError. Please move instance_id_prefix after fetch_inputs_and_outputs and add a regression test for the original five-position mapping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved instance_id_prefix after the existing fields and added a regression test that verifies the original five-position constructor mapping.

Comment thread CHANGELOG.md
ADDED

- Added `OrchestrationQuery.instance_id_prefix` to retrieve orchestration
instances whose IDs begin with a specified prefix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This API is also exposed through DurableTaskSchedulerClient and the sync/async Durable Functions clients by inheritance. The repository changelog policy therefore requires matching ## Unreleased entries in durabletask-azuremanaged/CHANGELOG.md and azure-functions-durable/CHANGELOG.md. Please document the inherited user-facing filter in both provider changelogs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added matching ## Unreleased entries to the Durable Task Scheduler and Azure Functions Durable changelogs.

andystaples and others added 2 commits August 13, 2026 10:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: abe44a4b-db94-4661-bb3b-2d7dd30b1e78
@andystaples

Copy link
Copy Markdown
Contributor Author

Resolves one half of #222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants