{"record":{"id":"d26536412dff1b9f","repo":"BoundaryML/baml","slug":"i-o-error-message","errorCode":null,"errorMessage":"I/O error: {message}","messagePattern":"I/O error: (.+?)","errorType":"exception","errorClass":"VmBamlError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_vm_types/src/errors.rs","lineNumber":119,"sourceCode":"    /// echo).\n    #[error(\"host contract violation: {message} [class={class_name:?}, lang={language:?}]\")]\n    HostContractViolation {\n        message: String,\n        class_name: Option<String>,\n        language: Option<String>,\n    },\n}\n\n/// An error value from the BAML standard library. Maps 1:1 to a `baml.errors.*` class.\n#[derive(Debug, Error, PartialEq, Clone)]\npub enum VmBamlError {\n    #[error(\"invalid argument: {message}\")]\n    InvalidArgument { message: String },\n\n    #[error(\"parse error: {message}\")]\n    ParseError { message: String },\n\n    #[error(\"I/O error: {message}\")]\n    Io { message: String },\n\n    #[error(\"timeout: {message}\")]\n    Timeout {\n        message: String,\n        duration_ms: Option<i64>,\n    },\n\n    #[error(\"unsupported: {message}\")]\n    Unsupported { message: String },\n\n    #[error(\"access error: {message}\")]\n    AccessError { message: String },\n\n    #[error(\"render prompt: {message}\")]\n    RenderPrompt { message: String },\n\n    #[error(\"LLM client error: {message}\")]","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_vm_types/src/errors.rs#L101-L137","documentation":"An error value from the BAML standard library, mapping to the `baml.errors.Io` class. It represents a generic input/output failure from a stdlib operation that touches the outside world (files, streams, subprocess I/O, etc.), with the underlying reason in `message`.","triggerScenarios":"A stdlib I/O call fails at the OS/host level: missing file or directory, closed stream, device error, or a host-reported I/O exception propagated into the VM.","commonSituations":"Reading a prompt file that doesn't exist at the given path; running in a container where the working directory or mounted volume differs; a stream being closed by the other side mid-operation.","solutions":["Verify paths and that the resource exists/permissions allow access before the I/O call.","Catch `baml.errors.Io` and surface a user-friendly message or fallback input source.","Check the environment (working directory, mounts, file permissions) where the program runs.","Inspect the wrapped `message` to identify the underlying OS error and address it directly."],"exampleFix":"// before\nlet raw = fs.read(\"prompts/p.txt\");\n// after\nlet raw = if fs.exists(\"prompts/p.txt\") {\n  fs.read(\"prompts/p.txt\")\n} else {\n  fs.read(\"prompts/default.txt\")\n};\n","handlingStrategy":"try-catch","validationCode":"// BAML: check resource presence before I/O\nif !fs.exists(path) {\n  return err(\"missing input file: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  let raw = fs.read(path);\n} catch e: baml.errors.Io {\n  return fallback_input() ?? rethrow_with_context(e.message);\n}","preventionTips":["Resolve paths relative to known roots; verify in the deployment environment.","Check file existence and permissions before I/O.","Handle host I/O exceptions in host wrappers so they map to clean error messages.","Test workflows in containers/environments mirroring production."],"tags":["io","filesystem","stdlib","baml"],"backgroundTag":"file-read-failed","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}