{"record":{"id":"b6d42014aea955e1","repo":"warpdotdev/warp","slug":"oz-run-id-env-var-is-set-but-is-not-valid-unicod","errorCode":null,"errorMessage":"{OZ_RUN_ID_ENV_VAR} is set but is not valid Unicode","messagePattern":"(.+?) is set but is not valid Unicode","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/artifact_upload.rs","lineNumber":303,"sourceCode":"\nfn ambient_task_id_from_conversation_metadata(\n    conversation_id: &str,\n    metadata: ServerAIConversationMetadata,\n) -> Result<AmbientAgentTaskId> {\n    metadata.ambient_agent_task_id.ok_or_else(|| {\n        anyhow!(\"Conversation '{conversation_id}' is not backed by a cloud agent task\")\n    })\n}\n\nfn parse_run_id(run_id: &str, error_prefix: &str) -> Result<AmbientAgentTaskId> {\n    parse_ambient_task_id(run_id, error_prefix)\n}\n\nfn load_env_run_id() -> Result<Option<String>> {\n    match env::var(OZ_RUN_ID_ENV_VAR) {\n        Ok(run_id) => Ok(Some(run_id)),\n        Err(env::VarError::NotPresent) => Ok(None),\n        Err(env::VarError::NotUnicode(_)) => Err(anyhow!(\n            \"{OZ_RUN_ID_ENV_VAR} is set but is not valid Unicode\"\n        )),\n    }\n}\n\nfn resolve_env_run_id(env_run_id: Option<String>) -> Result<AmbientAgentTaskId> {\n    let Some(run_id) = env_run_id else {\n        bail!(\"{OZ_RUN_ID_ENV_VAR} is not set\");\n    };\n\n    parse_run_id(&run_id, \"Invalid OZ_RUN_ID\")\n}\n\nfn resolve_upload_association_from_sources(\n    explicit_run_id: Option<AmbientAgentTaskId>,\n    explicit_conversation_id: Option<ServerConversationToken>,\n    conversation_task_id: Option<Result<AmbientAgentTaskId>>,\n    env_run_id: Option<String>,","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/artifact_upload.rs#L285-L321","documentation":"`load_env_run_id` reads OZ_RUN_ID to associate uploaded artifacts with the ambient agent task. `env::VarError::NotUnicode` means the variable's bytes are not valid UTF-8, so it can never parse as a task id and upload association fails.","triggerScenarios":"Running artifact upload where OZ_RUN_ID contains invalid UTF-8 bytes (set by a corrupted orchestration layer, CI env forwarding, or manual export from binary data) and no explicit --run-id was supplied.","commonSituations":"Corrupted runner env; CI env forwarding bugs; container images with broken encoding; hand-set env vars from non-text sources.","solutions":["Pass `--run-id <ambient task id>` explicitly and stop depending on the env var","Re-export OZ_RUN_ID with the valid task id string, or unset it","Fix the runner/harness that injects OZ_RUN_ID so it writes valid UTF-8"],"exampleFix":"# before\nOZ_RUN_ID=$'\\xff\\xfe' warp artifacts upload out.log\n# after\nwarp artifacts upload --run-id <ambient-task-id> out.log","handlingStrategy":"validation","validationCode":"fn env_run_id_usable() -> Option<String> {\n    std::env::var_os(OZ_RUN_ID_ENV_VAR)?.to_str().map(str::to_owned)\n}\n// Require Some(valid id) or an explicit --run-id before starting the upload.","typeGuard":"fn env_run_id_is_utf8() -> bool {\n    std::env::var_os(OZ_RUN_ID_ENV_VAR)\n        .map(|v| v.to_str().is_some())\n        .unwrap_or(true)\n}","tryCatchPattern":null,"preventionTips":["Validate env vars with var_os().to_str() before use","Inject OZ_RUN_ID only from validated task-id strings","Prefer explicit --run-id in scripts"],"tags":["environment","utf-8","env-var","artifact-upload"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}