warpdotdev/warp · error
{} is set but is not valid Unicode
Error message
{} is set but is not valid Unicode What it means
`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.
Source
Thrown at app/src/ai/agent_sdk/ambient.rs:1057
Duration::from_secs(STREAM_RETRY_BACKOFF_STEPS[index])
}
fn write_stream_record<T: Serialize>(record: &T) -> anyhow::Result<()> {
let mut stdout = std::io::stdout();
super::output::write_json_line(record, &mut stdout)?;
stdout.flush().context("unable to flush stdout")?;
Ok(())
}
fn task_id_from_run_id(run_id: &str) -> Option<AmbientAgentTaskId> {
run_id.parse().ok()
}
fn task_id_from_oz_run_id_env() -> anyhow::Result<Option<AmbientAgentTaskId>> {
match std::env::var(warp_cli::OZ_RUN_ID_ENV) {
Ok(run_id) => parse_ambient_task_id(&run_id, "Invalid OZ_RUN_ID").map(Some),
Err(std::env::VarError::NotPresent) => Ok(None),
Err(std::env::VarError::NotUnicode(_)) => Err(anyhow!(
"{} is set but is not valid Unicode",
warp_cli::OZ_RUN_ID_ENV
)),
}
}
fn task_id_for_message_send(sender_run_id: &str) -> anyhow::Result<Option<AmbientAgentTaskId>> {
match task_id_from_run_id(sender_run_id) {
Some(task_id) => Ok(Some(task_id)),
None => task_id_from_oz_run_id_env(),
}
}
#[derive(Debug, Clone)]
struct SendAgentMessageLogContext {
sender_run_id: String,
task_id: Option<String>,
target_agent_ids: Vec<String>,View on GitHub (pinned to e72fd7aacb)
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
Example fix
# before OZ_RUN_ID=$'bad\xff' warp agent send "hi" # after env -u OZ_RUN_ID warp agent send --run-id <valid-run-id> "hi"
Defensive patterns
Strategy: validation
Validate before calling
fn oz_run_id_valid_unicode() -> bool {
match std::env::var_os(warp_cli::OZ_RUN_ID_ENV) {
Some(v) => v.to_str().is_some(),
None => true,
}
}
// Bail with a clear message before invoking commands that consume OZ_RUN_ID. Type guard
fn valid_oz_run_id() -> Option<String> {
std::env::var_os(warp_cli::OZ_RUN_ID_ENV)?.to_str().map(str::to_owned)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {OZ_RUN_ID_ENV_VAR} is set but is not valid Unicode
- Attachment upload is not enabled
- Refusing to expire API key without confirmation in non-inter
- Conversation '{conversation_id}' is not backed by a cloud ag
- Failed to resolve artifact upload association for conversati
AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16).
Data as JSON: /api/errors/bccc447462432bf7.
Report an issue: GitHub.