affaan-m/ECC · error · anyhow::Error

Context graph observation #

Error message

Context graph observation #{observation_id} was not found

What it means

The `graph pin-observation` command toggles the pinned flag on a context graph observation by ID via `db.set_context_observation_pinned`. The DB layer returns `Ok(None)` when no observation with that ID exists, and the command converts that into this error instead of failing silently.

Solutions

  1. List context observations (`ecc2 graph ...` list output) and use a valid observation ID.
  2. Check the numeric ID for typos or off-by-one mistakes.
  3. If the observation was deleted, re-record it or pin a different one.
  4. Confirm you are operating on the same project database the observation was created in.

Example fix

// before (shell)
ecc2 graph pin-observation 87   # -> "Context graph observation #87 was not found"

// after
ecc2 graph list-observations    # find a valid ID
ecc2 graph pin-observation 42
Defensive patterns

Strategy: validation

Validate before calling

// shell: confirm the observation ID exists before pinning
ecc2 graph list-observations --json | jq -e --argjson id "$OBS_ID" 'map(.id) | index($id)' >/dev/null || { echo "observation #$OBS_ID not found"; exit 1; }

Type guard

fn observation_exists(db: &Db, id: i64) -> anyhow::Result<bool> {
    Ok(db.set_context_observation_pinned(id, false)?.is_some()) // read-style probe variant if available
}

Try / catch

// handle the None case as a lookup miss
match db.set_context_observation_pinned(observation_id, true)? {
    Some(obs) => print(obs),
    None => eprintln!("observation #{observation_id} not found; list observations to get valid IDs"),
}

Prevention

When it happens

Trigger: Running `ecc2 graph pin-observation <observation_id>` where the numeric ID does not match any row in the context observations table (including already-deleted observations).

Common situations: Using an ID copied from another database/project; the observation was pruned or deleted; typo in the numeric ID; assuming IDs are globally sequential across machines.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/5dce42770d263179. Report an issue: GitHub.

Appendix: source

Thrown at ecc2/src/main.rs:2414

                    &observation_type,
                    priority.into(),
                    pinned,
                    &summary,
                    &details,
                )?;
                if json {
                    println!("{}", serde_json::to_string_pretty(&observation)?);
                } else {
                    println!("{}", format_graph_observation_human(&observation));
                }
            }
            GraphCommands::PinObservation {
                observation_id,
                json,
            } => {
                let Some(observation) = db.set_context_observation_pinned(observation_id, true)?
                else {
                    return Err(anyhow::anyhow!(
                        "Context graph observation #{observation_id} was not found"
                    ));
                };
                if json {
                    println!("{}", serde_json::to_string_pretty(&observation)?);
                } else {
                    println!("{}", format_graph_observation_human(&observation));
                }
            }
            GraphCommands::UnpinObservation {
                observation_id,
                json,
            } => {
                let Some(observation) = db.set_context_observation_pinned(observation_id, false)?
                else {
                    return Err(anyhow::anyhow!(
                        "Context graph observation #{observation_id} was not found"
                    ));

View on GitHub (pinned to 8321021c54)