{"record":{"id":"4ea6f68f8a57e405","repo":"affaan-m/ECC","slug":"candidate-configuration-exceeds-1-mib","errorCode":null,"errorMessage":"candidate configuration exceeds 1 MiB","messagePattern":"candidate configuration exceeds 1 MiB","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/harness_eval.rs","lineNumber":198,"sourceCode":"use serde_json::Value;\nuse sha2::{Digest, Sha256};\nuse std::collections::{BTreeMap, BTreeSet};\n\n#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]\npub struct CandidateSpec {\n    pub id: String,\n    pub canonical_config: String,\n    pub trace_refs: Vec<String>,\n    pub evidence_refs: Vec<String>,\n}\n\nimpl CandidateSpec {\n    pub fn new(config: Value, trace_refs: Vec<String>, evidence_refs: Vec<String>) -> Result<Self> {\n        let trace_refs = normalize_refs(\"trace\", trace_refs)?;\n        let evidence_refs = normalize_refs(\"evidence\", evidence_refs)?;\n        let canonical_config = serde_json::to_string(&canonicalize(config))?;\n        if canonical_config.len() > 1024 * 1024 {\n            bail!(\"candidate configuration exceeds 1 MiB\");\n        }\n        let artifact = serde_json::to_string(&CanonicalCandidateArtifact {\n            config: serde_json::from_str(&canonical_config)?,\n            trace_refs: &trace_refs,\n            evidence_refs: &evidence_refs,\n        })?;\n        let id = sha256_hex(artifact.as_bytes());\n        Ok(Self {\n            id,\n            canonical_config,\n            trace_refs,\n            evidence_refs,\n        })\n    }\n\n    pub fn verify_integrity(&self) -> Result<()> {\n        self.verify_persisted_id(&self.id)?;\n        if self.id != self.id_for_v2()? {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/harness_eval.rs#L180-L216","documentation":"`CandidateSpec::new` serializes the candidate configuration to its canonical JSON form and enforces a hard 1 MiB (1024*1024 bytes) limit on the serialized string. Oversized configurations are rejected eagerly because they would bloat persisted artifacts and content-addressed IDs. The error means your `config` JSON value, once canonicalized, exceeds that size budget.","triggerScenarios":"Constructing a `CandidateSpec::new(config, trace_refs, evidence_refs)` whose `config` `serde_json::Value` canonicalizes to more than 1,048,576 bytes.","commonSituations":"Embedding large blobs (test fixtures, logs, datasets, base64 assets) directly in the candidate config instead of external file references; accidentally serializing an entire database dump or full environment object; accumulating many nested overrides from merged config layers.","solutions":["Shrink the config: remove bulky fields and reference external artifacts by path instead of inlining content (use trace_refs/evidence_refs for references).","Split the candidate into multiple smaller CandidateSpecs if the content genuinely needs to be large.","Compress or deduplicate repeated structures in the config before passing it in.","If the limit is too restrictive for your legitimate workload, raise the bound in `harness_eval.rs` deliberately (a library change, not a caller workaround)."],"exampleFix":"// before\nlet config = serde_json::json!({\n    \"fixtures\": large_fixture_json, // >1 MiB inlined\n});\nlet spec = CandidateSpec::new(config, trace_refs, evidence_refs)?;\n\n// after\nlet config = serde_json::json!({\n    \"fixtures_ref\": \"artifacts/fixtures.json\", // external reference\n});\nlet spec = CandidateSpec::new(config, trace_refs, evidence_refs)?;","handlingStrategy":"validation","validationCode":"fn config_size_ok(config: &serde_json::Value) -> bool {\n    let canonical = serde_json::to_string(&canonicalize(config.clone())).unwrap_or_default();\n    canonical.len() <= 1024 * 1024\n}","typeGuard":null,"tryCatchPattern":"match CandidateSpec::new(config, trace_refs, evidence_refs) {\n    Ok(s) => s,\n    Err(e) if e.to_string().contains(\"exceeds 1 MiB\") => {\n        eprintln!(\"Config too large; move bulky data to external refs\");\n        CandidateSpec::new(shrink_config(config), trace_refs, evidence_refs)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check serialized config size in dev/test before submitting candidates.","Store large fixtures and datasets as external files referenced via trace_refs/evidence_refs.","Ban blob-like fields (logs, base64 assets) from candidate configs by convention.","Set an alerting lint threshold below 1 MiB (e.g. 800 KiB) to catch growth early."],"tags":["config","size-limit","json","validation","rust"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}