QueryWorkflow error

I want my worklow to be the “source of truth” for the state of an entity. Only when the workflow is not running and has been archived I want the database to be the “source of truth”. I solve this by having my API first querying the workflow and if it gets an error back I look in the database. The query can answer with the errors specified below. What error should I treat as “its time to look in the database” and what error should I treat as “there is probably something wrong with temporal, looking in the database is not correct…”. Hopefully my question is clear.

bild

Only when the workflow is not running and has been archived I want the database to be the “source of truth”

Are you referring to the Temporal default persistence store here? Once a completed execution reaches namespace retention its removed from both persistence and visibility.

What error should I treat as “its time to look in the database”

NotFound
would mean the exec is not in Temporal persistence, could be either the execution for that workflowid you specify was never created or it was removed due to reaching retention.