{"record":{"id":"2bc65be157b7dde9","repo":"biomejs/biome","slug":"has-size-expected-expected-size","errorCode":null,"errorMessage":"{} has size {}, expected {expected_size}","messagePattern":"(.+?) has size (.+?), expected (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/codegen/src/unicode.rs","lineNumber":222,"sourceCode":"            .and_then(|properties| properties.validate(expected_version, expected_size))\n            .or_else(|_| {\n                let fetched = Self::fetch(cache_path, source_url)?\n                    .validate(expected_version, expected_size)?;\n                fetched.save_cache()?;\n                Ok(fetched)\n            })\n    }\n\n    fn validate(self, expected_version: &str, expected_size: usize) -> Result<Self> {\n        anyhow::ensure!(\n            self.raw\n                .lines()\n                .take(10)\n                .any(|line| line.contains(expected_version)),\n            \"{} does not contain Unicode version {expected_version}\",\n            self.path().display()\n        );\n        anyhow::ensure!(\n            self.raw.len() == expected_size,\n            \"{} has size {}, expected {expected_size}\",\n            self.path().display(),\n            self.raw.len()\n        );\n\n        Ok(self)\n    }\n\n    fn path(&self) -> PathBuf {\n        xtask_glue::project_root().join(self.cache_path)\n    }\n\n    /// Retrieve properties from the unicode website.\n    /// # Errors\n    /// Return an error if the HTTP request fails.\n    fn fetch(cache_path: &'static str, source_url: &str) -> Result<Self> {\n        let raw = ureq::get(source_url).call()?.into_body().read_to_string()?;","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/biomejs/biome/blob/3835945f0638c88162351318b7bc8b64c5f2fba7/xtask/codegen/src/unicode.rs#L204-L240","documentation":"This error is raised by `Properties::validate` in xtask/codegen/src/unicode.rs:222 when the Unicode data file (fetched from unicode.org or loaded from the local cache) has a byte length that differs from the hard-coded `expected_size`. The size check is an integrity guard: the code generator only trusts a known-good snapshot of Unicode property data, so any file whose total length differs from the pinned expectation is rejected. Note that the file must pass the version check first; a size mismatch means the content changed even if the version line matches.","triggerScenarios":"Running the xtask codegen (`cargo codegen unicode`) when `Properties::cached_or_fetch` obtains data whose `raw.len() != expected_size`. Concretely: (1) a re-fetched Unicode .txt file differs in byte size from the pinned `expected_size` constant (Unicode site updated the file, added/removed code points, changed line endings or trailing newline); (2) the cache file at `cache_path` was hand-edited, truncated, saved with CRLF/LF conversion, or written by a different tool that reformatted it; (3) a proxy/CDN or partial download returned a truncated or modified copy of the file; (4) the repository's checked-in cached file was touched (e.g. git checkout/autocrlf conversion) while the pinned size in the source was not updated.","commonSituations":"Most often hit after Unicode publishes a revised data file (e.g. a new Unicode version or an update to a property file like UnicodeData.txt) so the byte count no longer matches the constant in xtask/codegen. Also common on Windows with git autocrlf, which converts LF to CRLF in the cached file and changes its length, or after manually editing the cache to test something and forgetting to restore it.","solutions":["Delete the stale cache file at the path named in the error (relative to the project root) and re-run codegen so it re-fetches the exact file; if it still mismatches, the upstream file changed","If upstream data legitimately changed, update the `expected_size` argument passed to `Properties::cached_or_fetch` for that property to the new byte length (and bump `expected_version` if needed)","Check git status / `git diff` on the cached file; restore it with `git checkout -- <cache_path>` if it was unintentionally modified (common with autocrlf)","Verify the download is complete and unmodified: compare byte length or checksum of the fetched file against the one published by unicode.org; bypass proxies that rewrite content"],"exampleFix":"// before (xtask/codegen/src/unicode.rs, call site)\nProperties::cached_or_fetch(\n    \"xtask/codegen/unicode/UnicodeData.txt\",\n    UNICODE_DATA_URL,\n    \"16.0.0\",\n    1_934_576, // stale size\n)?;\n// after (re-measure the file: wc -c xtask/codegen/unicode/UnicodeData.txt)\nProperties::cached_or_fetch(\n    \"xtask/codegen/unicode/UnicodeData.txt\",\n    UNICODE_DATA_URL,\n    \"16.0.0\",\n    1_952_104, // new pinned size\n)?;","handlingStrategy":"validation","validationCode":"use std::fs;\nlet raw = fs::read_to_string(\"xtask/codegen/unicode/UnicodeData.txt\")?;\nif raw.len() != 1_934_576 {\n    // stale or modified cache: remove it so codegen re-fetches\n    let _ = fs::remove_file(\"xtask/codegen/unicode/UnicodeData.txt\");\n}\n// Windows users: confirm git isn't converting line endings\n// git config core.autocrlf  # should be false/input for this repo","typeGuard":null,"tryCatchPattern":"match Properties::cached_or_fetch(CACHE_PATH, URL, VERSION, EXPECTED_SIZE) {\n    Ok(props) => generate(props),\n    Err(e) if e.to_string().contains(\"has size\") => {\n        // size mismatch: drop the cache and retry with a fresh fetch\n        let _ = std::fs::remove_file(CACHE_PATH);\n        generate(Properties::cached_or_fetch(CACHE_PATH, URL, VERSION, EXPECTED_SIZE)?);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Set `git config core.autocrlf false` (or input) so the cached Unicode files are never line-ending converted","Never hand-edit the cached Unicode data files; delete them instead so codegen re-fetches pristine copies","When bumping the Unicode version, re-pin `expected_size` (and `expected_version`) in the same commit by measuring the new file with `wc -c`","Run codegen behind a stable network or verify the fetched file's checksum against unicode.org to catch truncated/rewritten downloads"],"tags":["unicode","codegen","integrity-check","file-size","build-tooling"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"3835945f0638c88162351318b7bc8b64c5f2fba7","analyzedAt":"2026-09-13T15:11:16.919Z","contentChangedAt":"2026-09-13T15:11:16.919Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}