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

graph sync does not accept a session ID when --all is set

Error message

graph sync does not accept a session ID when --all is set

What it means

This validation error fires in the graph sync command when the user passes both `--all` and a `session_id`. The two options are mutually exclusive: `--all` syncs every session (resolved_session_id becomes `None`), while a session ID targets one session. The command rejects the ambiguous combination up front via `anyhow::anyhow!`.

Solutions

  1. Remove `--all` if you want to sync only the given session ID.
  2. Remove the `--session <id>` argument if you want to sync everything.
  3. Update wrapping scripts to pass either `--all` or a session ID, never both.
  4. Run `ecc graph sync --help` to confirm the option semantics.

Example fix

// before
$ ecc graph sync --all --session abc-123
error: graph sync does not accept a session ID when --all is set
// after
$ ecc graph sync --session abc-123   # one session
# or
$ ecc graph sync --all               # all sessions
Defensive patterns

Strategy: validation

Validate before calling

# Script guard: pass exactly one targeting mode
if [ -n "$SESSION_ID" ] && [ "$ALL" = "1" ]; then
  echo "choose either --all or --session, not both" >&2; exit 2
fi

Prevention

When it happens

Trigger: Invoking `ecc graph sync --all --session <id>` (or passing a positional session ID together with `--all`), which makes the target session ambiguous.

Common situations: Copy-pasting a full example command from docs and appending `--all`; shell scripts that append `--all` unconditionally while already passing a session; users unsure whether `--all` overrides an explicit session.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at ecc2/src/main.rs:2555

                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"
                    ));
                }
                sync_runtime_session_metrics(&db, &cfg)?;
                let resolved_session_id = if all {
                    None
                } else {
                    Some(resolve_session_id(
                        &db,
                        session_id.as_deref().unwrap_or("latest"),
                    )?)
                };
                let stats = db.sync_context_graph_history(resolved_session_id.as_deref(), limit)?;
                if json {
                    println!("{}", serde_json::to_string_pretty(&stats)?);
                } else {
                    println!(
                        "{}",

View on GitHub (pinned to 8321021c54)