{"record":{"id":"f366af8e35a747ad","repo":"affaan-m/ECC","slug":"valid-candidate-id-and-bounded-activation-evidence","errorCode":null,"errorMessage":"valid candidate id and bounded activation evidence reference are required","messagePattern":"valid candidate id and bounded activation evidence reference are required","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/session/store.rs","lineNumber":5401,"sourceCode":"        self.conn.execute(\n            \"INSERT INTO harness_candidates (id, canonical_config_json, trace_refs_json, evidence_refs_json, created_at)\n             VALUES (?1, ?2, ?3, ?4, ?5) ON CONFLICT(id) DO NOTHING\",\n            rusqlite::params![candidate.id, candidate.canonical_config, trace_json, evidence_json, chrono::Utc::now().to_rfc3339()],\n        )?;\n        let stored: (String, String, String) = self.conn.query_row(\n            \"SELECT canonical_config_json, trace_refs_json, evidence_refs_json FROM harness_candidates WHERE id = ?1\",\n            [&candidate.id],\n            |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)),\n        )?;\n        if stored != expected {\n            anyhow::bail!(\"candidate id collision with different immutable content\");\n        }\n        Ok(())\n    }\n\n    pub fn activate_initial_harness(&self, candidate_id: &str, evidence_ref: &str) -> Result<()> {\n        if candidate_id.len() != 64 || evidence_ref.trim().is_empty() || evidence_ref.len() > 4096 {\n            anyhow::bail!(\n                \"valid candidate id and bounded activation evidence reference are required\"\n            );\n        }\n        let tx = self.conn.unchecked_transaction()?;\n        let stored_candidate_id = Self::resolve_harness_candidate_id(&tx, candidate_id)?;\n        if tx\n            .query_row(\n                \"SELECT candidate_id FROM active_harness_config WHERE slot = 'default'\",\n                [],\n                |row| row.get::<_, String>(0),\n            )\n            .optional()?\n            .is_some()\n        {\n            anyhow::bail!(\"an active harness configuration already exists\");\n        }\n        let now = chrono::Utc::now().to_rfc3339();\n        tx.execute(\"INSERT INTO active_harness_config (slot, candidate_id, updated_at) VALUES ('default', ?1, ?2)\", rusqlite::params![stored_candidate_id, now])?;","sourceCodeStart":5383,"sourceCodeEnd":5419,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/session/store.rs#L5383-L5419","documentation":"activate_initial_harness enforces input bounds: candidate_id must be exactly 64 chars (the v2 hex digest length) and evidence_ref must be non-empty after trimming and at most 4096 chars. Failing any one bails with this single aggregate message.","triggerScenarios":"Calling activate_initial_harness(candidate_id, evidence_ref) where candidate_id.len() != 64, evidence_ref.trim().is_empty(), or evidence_ref.len() > 4096.","commonSituations":"Passing a legacy (non-64-char) id; passing a full URL or JSON blob as evidence that exceeds 4096 chars; whitespace-only evidence; passing an Option<None> rendered as empty.","solutions":["Validate candidate_id is exactly 64 hex characters before calling.","Trim evidence_ref and assert 1 <= len <= 4096.","Store large evidence externally (object store, file) and pass only a short reference URI/digest."],"exampleFix":"// before\nstore.activate_initial_harness(&candidate_id, &evidence_ref)?;\n\n// after\nfn is_v2_id(s: &str) -> bool {\n    s.len() == 64 && s.bytes().all(|b| b.is_ascii_hexdigit())\n}\nif !is_v2_id(&candidate_id) {\n    anyhow::bail!(\"candidate_id must be a 64-char hex digest\");\n}\nlet evidence_ref = evidence_ref.trim();\nif evidence_ref.is_empty() || evidence_ref.len() > 4096 {\n    anyhow::bail!(\"evidence_ref must be 1..=4096 chars\");\n}\nstore.activate_initial_harness(&candidate_id, evidence_ref)?;","handlingStrategy":"validation","validationCode":"fn is_v2_id(s: &str) -> bool {\n    s.len() == 64 && s.bytes().all(|b| b.is_ascii_hexdigit())\n}\n\nlet evidence_ref = evidence_ref.trim();\nif !is_v2_id(&candidate_id)\n    || evidence_ref.is_empty()\n    || evidence_ref.len() > 4096\n{\n    return Err(anyhow::anyhow!(\"invalid activation arguments\"));\n}\nstore.activate_initial_harness(&candidate_id, evidence_ref)?;","typeGuard":"fn valid_activation_args(candidate_id: &str, evidence_ref: &str) -> bool {\n    let e = evidence_ref.trim();\n    candidate_id.len() == 64 && !e.is_empty() && e.len() <= 4096\n}","tryCatchPattern":"match store.activate_initial_harness(&candidate_id, &evidence_ref) {\n    Ok(()) => { /* activated */ }\n    Err(e) if e.to_string().contains(\"valid candidate id and bounded activation\") => {\n        // fix the candidate_id length or the evidence_ref size and retry\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Centralize the 64-char hex-id check in one helper and use it at every entry point.","Keep evidence_ref a short reference (URI/digest), never an inline payload.","Add a unit test that asserts the exact bounds (64, 1..=4096)."],"tags":["rust","harness","validation","bounds"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}