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

Context graph entity not found

Error message

Context graph entity not found: {entity_id}

What it means

Thrown by the context graph entity-detail command when `db.get_context_entity_detail(entity_id, limit)` returns `None`: no context graph entity matches the provided `entity_id`. Entities (files, symbols, topics, etc.) are created during graph indexing, so a missing ID means it was never indexed or has since been removed. The error aborts before printing any detail output.

Solutions

  1. Search the graph for the entity (list/search entities command) to get its current exact ID.
  2. Run graph sync (`ecc graph sync` or session metrics sync) so the entity gets indexed, then retry.
  3. Confirm you're pointing at the right database/profile; IDs are not portable across state stores.
  4. If the entity was pruned, regenerate it by re-syncing the originating session.

Example fix

// before
$ ecc context graph entity-detail --id src/main.rs
error: Context graph entity not found: src/main.rs
// after
$ ecc graph sync
$ ecc context graph entities --search "main.rs"
$ ecc context graph entity-detail --id <exact-id-from-listing>
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the entity exists before requesting detail
ENTITY_ID=$(ecc context graph entities --search "main.rs" --json | jq -r '.[0].id // empty')
[ -n "$ENTITY_ID" ] && ecc context graph entity-detail --id "$ENTITY_ID"

Try / catch

match db.get_context_entity_detail(id, limit)? {
    Some(detail) => print_detail(&detail),
    None => eprintln!("entity {id} not indexed; run graph sync first"),
}

Prevention

When it happens

Trigger: Running the entity detail subcommand with an ID that was mistyped, generated on a different machine/database, or belongs to an entity removed by graph pruning/compaction; also when the graph was never synced so the entity was never inserted.

Common situations: Copying an entity ID from a teammate's session or CI run; referencing an entity after a database reset; querying before the first graph sync populated entities; casing/format mismatch in the identifier.

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/1cedef65302a16c8. Report an issue: GitHub.

Appendix: source

Thrown at ecc2/src/main.rs:2540

                    db.recall_context_entities(resolved_session_id.as_deref(), &query, limit)?;
                if json {
                    println!("{}", serde_json::to_string_pretty(&entries)?);
                } else {
                    println!(
                        "{}",
                        format_graph_recall_human(&entries, resolved_session_id.as_deref(), &query)
                    );
                }
            }
            GraphCommands::Show {
                entity_id,
                limit,
                json,
            } => {
                let detail = db
                    .get_context_entity_detail(entity_id, limit)?
                    .ok_or_else(|| {
                        anyhow::anyhow!("Context graph entity not found: {entity_id}")
                    })?;
                if json {
                    println!("{}", serde_json::to_string_pretty(&detail)?);
                } else {
                    println!("{}", format_graph_entity_detail_human(&detail));
                }
            }
            GraphCommands::Sync {
                session_id,
                all,
                limit,
                json,
            } => {
                if all && session_id.is_some() {
                    return Err(anyhow::anyhow!(
                        "graph sync does not accept a session ID when --all is set"
                    ));
                }

View on GitHub (pinned to 8321021c54)