Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WORKFLOW SDK BUG] Get workflow state raising exception for instances that do not exist #745

Open
ajstewart opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels

Comments

@ajstewart
Copy link

Expected Behavior

When I run:

state = wf_client.get_workflow_state(instance_id=my_id)

I expect to receive a None response when the instance does not exist, as defined by the docs:

The current state of the workflow instance, or None if the workflow instance does not exist.

Actual Behavior

I am getting an Exception when the instance does not exist:

== APP == grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
== APP == 	status = StatusCode.UNKNOWN
== APP == 	details = "error from internal actor: no such instance exists"
== APP == 	debug_error_string = "UNKNOWN:Error received from peer ipv4:127.0.0.1:55008 {grpc_message:"error from internal actor: no such instance exists", grpc_status:2, created_time:"2024-10-23T10:46:36.084357+01:00"}"

Steps to Reproduce the Problem

The following small app can reproduce by calling the endpoint

import dapr.ext.workflow as wf
import uvicorn

from fastapi import FastAPI


def hello_world(ctx: wf.WorkflowActivityContext):
    """Hello world workflow."""
    return "Hello world!"


def dummy_workflow(ctx: wf.DaprWorkflowContext):
    """Dummy workflow."""
    result = yield ctx.call_activity(hello_world)
    return result


wf_runtime = wf.WorkflowRuntime()
wf_runtime.register_workflow(dummy_workflow)
wf_runtime.register_activity(hello_world)

wf_client = wf.DaprWorkflowClient()

wf_runtime.start()


app = FastAPI()


@app.get("/workflow/{instance_id}")
def get_workflow_state(instance_id: str):
    """Get the workflow state."""
    state = wf_client.get_workflow_state(instance_id=instance_id)

    if state is None:
        return {"message": "Workflow not found"}

    return {"status": state.runtime_status}


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=5001)

Release Note

RELEASE NOTE:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants