affaan-m/ECC · error

Context graph entity name cannot be empty

Error message

Context graph entity name cannot be empty

What it means

Companion to the entity-type check: after trimming, an empty name produces `Context graph entity name cannot be empty`. The name, together with type and normalized path, forms the entity key, so an empty name would create an invalid key.

Solutions

  1. Ensure the caller supplies a non-empty name; skip entities with blank labels.
  2. Validate extraction output (reject empty capture groups) before persisting.
  3. Make the name required at the API boundary (Option or constructor validation) so empty values never reach the store.
  4. Normalize/trim the name upstream and fall back to a placeholder only when semantically valid.

Example fix

// before
let name = captures.get(1).map(|m| m.as_str()).unwrap_or("");
store.upsert_context_graph_entity(entity_type, name, path, &summary, &meta)?;
// after
if let Some(m) = captures.get(1).filter(|m| !m.as_str().trim().is_empty()) {
    store.upsert_context_graph_entity(entity_type, m.as_str().trim(), path, &summary, &meta)?;
}
Defensive patterns

Strategy: validation

Validate before calling

const n = name.trim();
if (!n) return; // skip blank entities
await api.upsertContextGraphEntity(entityType, n, path, summary, metadata);

Type guard

function hasName(v) { return typeof v === 'string' && v.trim().length > 0; }

Try / catch

try {
    store.upsert_context_graph_entity(&etype, &name, path, &summary, &meta)?;
} catch (e) {
    if (String(e).includes('entity name cannot be empty')) {
        log::debug!("dropped entity with empty name");
    } else throw e;
}

Prevention

When it happens

Trigger: upsert_context_graph_entity called with name = "" or whitespace — e.g. extracting an entity label from parsed content that yielded an empty match, or a caller defaulting name to String::new().

Common situations: Regex/AST extraction returning empty capture groups; spreadsheet/CSV imports with blank name cells; UI forms submitted without the name field.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at ecc2/src/session/store.rs:3103

        Ok(stats)
    }

    pub fn upsert_context_entity(
        &self,
        session_id: Option<&str>,
        entity_type: &str,
        name: &str,
        path: Option<&str>,
        summary: &str,
        metadata: &BTreeMap<String, String>,
    ) -> Result<ContextGraphEntity> {
        let entity_type = entity_type.trim();
        if entity_type.is_empty() {
            return Err(anyhow::anyhow!("Context graph entity type cannot be empty"));
        }
        let name = name.trim();
        if name.is_empty() {
            return Err(anyhow::anyhow!("Context graph entity name cannot be empty"));
        }

        let normalized_path = path.map(str::trim).filter(|value| !value.is_empty());
        let summary = summary.trim();
        let entity_key = context_graph_entity_key(entity_type, name, normalized_path);
        let metadata_json = serde_json::to_string(metadata)
            .context("Failed to serialize context graph metadata")?;
        let timestamp = chrono::Utc::now().to_rfc3339();

        self.conn.execute(
            "INSERT INTO context_graph_entities (
                session_id, entity_key, entity_type, name, path, summary, metadata_json, created_at, updated_at
             )
             VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?8)
             ON CONFLICT(entity_key) DO UPDATE SET
                session_id = COALESCE(excluded.session_id, context_graph_entities.session_id),
                summary = CASE
                    WHEN excluded.summary <> '' THEN excluded.summary

View on GitHub (pinned to 8321021c54)