tinyhumansai/openhuman · error · anyhow::Error

flow '{id}' not found after update

Error message

flow '{id}' not found after update

What it means

set_enabled updated a flow's enabled flag but the follow-up fetch of the updated record found no row for the id: the UPDATE reported zero changed rows (or a concurrent delete removed it between write and read). Indicates the flow id does not exist in flow_definitions, not a SQL failure.

Source

Thrown at src/openhuman/flows/store.rs:469

    tracing::debug!(flow_id = %id, "[flows] removed flow definition");
    Ok(())
}

/// Toggles a flow's `enabled` flag, returning the updated record.
pub fn set_enabled(config: &Config, id: &str, enabled: bool) -> Result<Flow> {
    let now = Utc::now().to_rfc3339();
    let changed = with_connection(config, |conn| {
        conn.execute(
            "UPDATE flow_definitions SET enabled = ?1, updated_at = ?2 WHERE id = ?3",
            params![if enabled { 1 } else { 0 }, now, id],
        )
        .context("Failed to update flow enabled state")
    })?;
    if changed == 0 {
        anyhow::bail!("flow '{id}' not found");
    }
    tracing::debug!(flow_id = %id, enabled, "[flows] set_enabled");
    get_flow(config, id)?.ok_or_else(|| anyhow::anyhow!("flow '{id}' not found after update"))
}

/// How many revision snapshots to retain per flow (audit F6). Older ones are
/// pruned on each new capture.
const MAX_REVISIONS_PER_FLOW: usize = 20;

/// Failure modes of [`update_flow_graph`] that the caller must distinguish:
/// a genuine not-found, an optimistic-concurrency conflict (carrying the
/// current server flow so the UI can diff/reload), or a store error.
#[derive(Debug)]
pub enum FlowUpdateError {
    /// No flow with that id exists.
    NotFound,
    /// The flow changed since `expected_updated_at` was observed — the write
    /// was refused to avoid clobbering. Carries the current server flow.
    Conflict(Box<Flow>),
    /// An underlying store failure.
    Store(anyhow::Error),

View on GitHub (pinned to 7491200858)

Solutions

  1. Verify the flow id exists (list flows first)
  2. Handle concurrent deletion by re-checking before toggling
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/openhuman/flows/store.rs:469 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/9208218e212f079e. Report an issue: GitHub.