{"record":{"id":"a4e1f0045a74464b","repo":"Hmbown/CodeWhale","slug":"continual-harness-field-must-be-min-max-ch","errorCode":null,"errorMessage":"continual harness {field} must be {min}..={max} characters","messagePattern":"continual harness (.+?) must be (.+?)\\.\\.=(.+?) characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/continual_harness.rs","lineNumber":348,"sourceCode":"            state_path.display()\n        )\n    })?;\n    operation()\n}\n\nfn validate_refinement(mut refinement: HarnessRefinement) -> Result<HarnessRefinement> {\n    refinement.title = normalize_bounded(\"title\", refinement.title, MAX_TITLE_CHARS, 1)?;\n    refinement.content = normalize_bounded(\"content\", refinement.content, MAX_CONTENT_CHARS, 1)?;\n    refinement.evidence =\n        normalize_bounded(\"evidence\", refinement.evidence, MAX_EVIDENCE_CHARS, 16)?;\n    Ok(refinement)\n}\n\nfn normalize_bounded(field: &str, value: String, max: usize, min: usize) -> Result<String> {\n    let value = value.trim().to_string();\n    let len = value.chars().count();\n    if len < min || len > max {\n        bail!(\"continual harness {field} must be {min}..={max} characters\");\n    }\n    Ok(value)\n}\n\nfn truncate_chars(value: &str, max: usize) -> String {\n    let mut chars = value.chars();\n    let head: String = chars.by_ref().take(max).collect();\n    if chars.next().is_some() {\n        format!(\"{head}…\")\n    } else {\n        head\n    }\n}\n\nfn escape_for_prompt(value: &str) -> String {\n    value\n        .replace('&', \"&amp;\")\n        .replace('<', \"&lt;\")","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/continual_harness.rs#L330-L366","documentation":"normalize_bounded enforces per-field length limits on harness refinements (title and content 1..max, evidence 16..max characters after trimming); this error fires when a field falls outside its min..=max range, naming the field and bounds.","triggerScenarios":"Calling validate_refinement with a field value whose trimmed character count is < min or > max for that field's bounds.","commonSituations":"Pasting in a refinement description longer than the cap, submitting whitespace-only text that trims to empty (below min), or counting bytes instead of characters for multibyte input.","solutions":["Trim and check the character count (chars().count(), not byte length) of your value before calling","Shorten the value to within max characters","Provide a longer value if it is below min (including non-whitespace content)"],"exampleFix":"// before\nlet value = \"  \".to_string(); // trims to 0 chars, min is 1\n// after\nlet value = \"narrow the search scope\".trim().to_string();","handlingStrategy":"validation","validationCode":"fn in_bounds(s: &str, min: usize, max: usize) -> bool {\n    let n = s.trim().chars().count();\n    n >= min && n <= max\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always trim and count chars() (not bytes) before submitting","Enforce field length limits in your own input UI","Reject whitespace-only input before calling the API"],"tags":["validation","input-length","string"],"backgroundTag":"invalid-argument-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}