{"record":{"id":"12b7f77503796a4c","repo":"astrid-runtime/astrid","slug":"wrapped-utf-8-conversion-error-from-invite-store","errorCode":null,"errorMessage":"(wrapped UTF-8 conversion error from invite store bytes)","messagePattern":"\\(wrapped UTF-8 conversion error from invite store bytes\\)","errorType":"validation","errorClass":"InviteStoreError","httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/invite/mod.rs","lineNumber":529,"sourceCode":"        {\n            let _ = &self.path;\n            return Ok(Vec::new());\n        }\n        #[cfg(not(all(target_arch = \"wasm32\", target_os = \"unknown\")))]\n        {\n            self.load_from_disk()\n        }\n    }\n\n    #[cfg(not(all(target_arch = \"wasm32\", target_os = \"unknown\")))]\n    fn load_from_disk(&self) -> Result<Vec<Invite>, InviteStoreError> {\n        let bytes = match std::fs::read(&self.path) {\n            Ok(b) => b,\n            Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),\n            Err(e) => return Err(InviteStoreError::Io(e)),\n        };\n        let text = std::str::from_utf8(&bytes).map_err(|e| {\n            InviteStoreError::Io(std::io::Error::new(std::io::ErrorKind::InvalidData, e))\n        })?;\n        if text.trim().is_empty() {\n            if let Err(error) = self.save_to_disk(&[]) {\n                warn!(\n                    path = %self.path.display(),\n                    %error,\n                    \"could not normalize empty invite store\"\n                );\n            }\n            return Ok(Vec::new());\n        }\n        let probe: SchemaProbe = toml::from_str(text).map_err(InviteStoreError::Toml)?;\n        if probe.schema_version > STORE_SCHEMA_VERSION {\n            return Err(InviteStoreError::Io(std::io::Error::new(\n                std::io::ErrorKind::InvalidData,\n                format!(\n                    \"invite store schema {} is newer than supported schema {STORE_SCHEMA_VERSION}\",\n                    probe.schema_version","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/invite/mod.rs#L511-L547","documentation":"The invite store file on disk is read as raw bytes and must be valid UTF-8 (TOML). If `str::from_utf8` fails, the underlying UTF-8 error is wrapped in an `io::Error` with `InvalidData` and rethrown as an `InviteStoreError::Io`.","triggerScenarios":"Calling `load` → `load_from_disk` when the invite store file contains bytes that are not valid UTF-8 (binary content, wrong encoding, corruption).","commonSituations":"The store file was edited with a tool that saved UTF-16 or Latin-1; the file got corrupted or truncated mid-write; a binary file was copied over the store path.","solutions":["Check the file encoding (`file` command) and convert it to UTF-8, or restore a known-good copy.","Delete the corrupt store file so the store starts empty (pending invites will need re-issuing).","Fix the tooling or editor that wrote non-UTF-8 content to the store."],"exampleFix":"# before\niconv -f UTF-16 -t UTF-8 corrupt.toml > invites.toml  # wrong source encoding\n# after\niconv -f UTF-16LE -t UTF-8 corrupt.toml > invites.toml && astrid invites list","handlingStrategy":"validation","validationCode":"let bytes = std::fs::read(store_path)?;\nif std::str::from_utf8(&bytes).is_err() {\n    eprintln!(\"invite store is not valid UTF-8; restore or remove it\");\n    return Err(MyError::CorruptStore);\n}","typeGuard":"fn is_utf8_file(p: &std::path::Path) -> bool {\n    std::fs::read(p).map(|b| std::str::from_utf8(&b).is_ok()).unwrap_or(false)\n}","tryCatchPattern":"match store.load() {\n    Err(InviteStoreError::Io(e)) if e.kind() == std::io::ErrorKind::InvalidData => {\n        warn!(\"corrupt/non-UTF-8 invite store, starting empty\");\n        InviteStore::empty()\n    }\n    other => other?,\n}","preventionTips":["Edit invite store files only with UTF-8-safe editors (`:set encoding=utf-8` in vim).","Back up the store before manual edits.","Never copy binary files over the store path; verify with `file` before replacing."],"tags":["encoding","utf-8","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}