{"record":{"id":"bccc447462432bf7","repo":"warpdotdev/warp","slug":"is-set-but-is-not-valid-unicode","errorCode":null,"errorMessage":"{} is set but is not valid Unicode","messagePattern":"(.+?) is set but is not valid Unicode","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/ambient.rs","lineNumber":1057,"sourceCode":"    Duration::from_secs(STREAM_RETRY_BACKOFF_STEPS[index])\n}\n\nfn write_stream_record<T: Serialize>(record: &T) -> anyhow::Result<()> {\n    let mut stdout = std::io::stdout();\n    super::output::write_json_line(record, &mut stdout)?;\n    stdout.flush().context(\"unable to flush stdout\")?;\n    Ok(())\n}\n\nfn task_id_from_run_id(run_id: &str) -> Option<AmbientAgentTaskId> {\n    run_id.parse().ok()\n}\n\nfn task_id_from_oz_run_id_env() -> anyhow::Result<Option<AmbientAgentTaskId>> {\n    match std::env::var(warp_cli::OZ_RUN_ID_ENV) {\n        Ok(run_id) => parse_ambient_task_id(&run_id, \"Invalid OZ_RUN_ID\").map(Some),\n        Err(std::env::VarError::NotPresent) => Ok(None),\n        Err(std::env::VarError::NotUnicode(_)) => Err(anyhow!(\n            \"{} is set but is not valid Unicode\",\n            warp_cli::OZ_RUN_ID_ENV\n        )),\n    }\n}\n\nfn task_id_for_message_send(sender_run_id: &str) -> anyhow::Result<Option<AmbientAgentTaskId>> {\n    match task_id_from_run_id(sender_run_id) {\n        Some(task_id) => Ok(Some(task_id)),\n        None => task_id_from_oz_run_id_env(),\n    }\n}\n\n#[derive(Debug, Clone)]\nstruct SendAgentMessageLogContext {\n    sender_run_id: String,\n    task_id: Option<String>,\n    target_agent_ids: Vec<String>,","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/ambient.rs#L1039-L1075","documentation":"`task_id_from_oz_run_id_env` reads the OZ_RUN_ID environment variable that the Oz cloud-runner orchestration injects to identify the current ambient agent task. `std::env::var` returns `VarError::NotUnicode` when the variable's raw bytes are not valid UTF-8, so the value can never parse as an AmbientAgentTaskId and the command aborts.","triggerScenarios":"Running a message-send/ambient command where no valid sender run id was passed and the OZ_RUN_ID fallback hits `Err(VarError::NotUnicode(_))` — the variable was exported with non-UTF-8 bytes by a launcher, script, or CI secrets mechanism.","commonSituations":"CI systems forwarding arbitrary bytes in env vars; a corrupted runner harness; exporting OZ_RUN_ID from a binary file or mangled locale; container images with broken encoding settings.","solutions":["Unset the variable so other identification paths apply: `env -u OZ_RUN_ID <command>`","Re-export it with a valid UTF-8 task id: `export OZ_RUN_ID=<valid ambient task id>`","Fix the upstream launcher/harness that injects OZ_RUN_ID so it always writes valid UTF-8","Pass the run id explicitly as a CLI argument instead of relying on the env var"],"exampleFix":"# before\nOZ_RUN_ID=$'bad\\xff' warp agent send \"hi\"\n# after\nenv -u OZ_RUN_ID warp agent send --run-id <valid-run-id> \"hi\"","handlingStrategy":"validation","validationCode":"fn oz_run_id_valid_unicode() -> bool {\n    match std::env::var_os(warp_cli::OZ_RUN_ID_ENV) {\n        Some(v) => v.to_str().is_some(),\n        None => true,\n    }\n}\n// Bail with a clear message before invoking commands that consume OZ_RUN_ID.","typeGuard":"fn valid_oz_run_id() -> Option<String> {\n    std::env::var_os(warp_cli::OZ_RUN_ID_ENV)?.to_str().map(str::to_owned)\n}","tryCatchPattern":null,"preventionTips":["Validate env vars with var_os().to_str() before running dependent commands","Only set OZ_RUN_ID from validated task-id strings in harnesses","Prefer explicit --run-id over env-dependent identification in scripts"],"tags":["environment","utf-8","env-var","ambient-agent","ci"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}