{"record":{"id":"070dd3fe0da83ab8","repo":"sigoden/aichat","slug":"invalid-wrap-value","errorCode":null,"errorMessage":"Invalid wrap value","messagePattern":"Invalid wrap value","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/config/mod.rs","lineNumber":838,"sourceCode":"        match has_rag {\n            true => update_rag(config, |rag| {\n                rag.set_top_k(value)?;\n                Ok(())\n            })?,\n            false => config.write().rag_top_k = value,\n        }\n        Ok(())\n    }\n\n    pub fn set_wrap(&mut self, value: &str) -> Result<()> {\n        if value == \"no\" {\n            self.wrap = None;\n        } else if value == \"auto\" {\n            self.wrap = Some(value.into());\n        } else {\n            value\n                .parse::<u16>()\n                .map_err(|_| anyhow!(\"Invalid wrap value\"))?;\n            self.wrap = Some(value.into())\n        }\n        Ok(())\n    }\n\n    pub fn set_max_output_tokens(&mut self, value: Option<isize>) {\n        match self.role_like_mut() {\n            Some(role_like) => {\n                let mut model = role_like.model().clone();\n                model.set_max_tokens(value, true);\n                role_like.set_model(model);\n            }\n            None => {\n                self.model.set_max_tokens(value, true);\n            }\n        };\n    }\n","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/config/mod.rs#L820-L856","documentation":"Validation error in GlobalConfig::set_wrap when the value is neither 'no', 'auto', nor parseable as u16. The wrap setting accepts only those three forms; anything else fails the integer parse and bails. The input at fault is the malformed wrap value string.","triggerScenarios":"Calling `set_wrap` with a string that is neither \"auto\"/null nor a valid u16 (e.g. \"80ch\", \"true\", \"1_000\", \"70000\" which overflows u16, or a negative number).","commonSituations":"Typing `/wrap 80ch` or `/wrap none` in the REPL; pasting a width beyond 65535; config file containing a wrapped string value.","solutions":["Pass a plain integer width (e.g. `80`).","Use `auto` for automatic width detection.","Use null/unset to disable wrapping.","Ensure the number fits in 0–65535 (u16)."],"exampleFix":"// before\nconfig.set_wrap(\"80ch\")?;\n\n// after\nconfig.set_wrap(\"80\")?; // or \"auto\"","handlingStrategy":"validation","validationCode":"// Rust\nfn is_valid_wrap(v: &str) -> bool {\n    v == \"auto\" || v.parse::<u16>().is_ok()\n}","typeGuard":null,"tryCatchPattern":"// REPL usage\nif !is_valid_wrap(input) { eprintln!(\"Usage: /wrap auto|<width 0-65535>\"); }","preventionTips":["Only pass \"auto\" or an integer within 0–65535.","Strip unit suffixes like \"ch\" or \"px\" from user input before calling.","Sanitize config file values on load."],"tags":["config","validation","cli"],"backgroundTag":"invalid-config-value","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}