nikivdev/code · error

FLOW_CODEX_MAPLE_HOSTED_ENDPOINT and FLOW_CODEX_MAPLE_HOSTED

Error message

FLOW_CODEX_MAPLE_HOSTED_ENDPOINT and FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY must both be set

What it means

Same paired-variable contract as the local target but for the hosted Maple ingest: `FLOW_CODEX_MAPLE_HOSTED_ENDPOINT` and `FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY` must be set together or not at all. A half-configured hosted target aborts config parsing in `parse_maple_exporter_config_from_env`, used by `status` and `flush`.

Source

Thrown at src/codex_telemetry.rs:261

            traces_endpoint: endpoint,
            ingest_key: key,
        }),
        (None, None) => {}
        _ => anyhow::bail!(
            "FLOW_CODEX_MAPLE_LOCAL_ENDPOINT and FLOW_CODEX_MAPLE_LOCAL_INGEST_KEY must both be set"
        ),
    }

    match (
        env_non_empty_with_store("FLOW_CODEX_MAPLE_HOSTED_ENDPOINT", &mut personal_env),
        env_non_empty_with_store("FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY", &mut personal_env),
    ) {
        (Some(endpoint), Some(key)) => targets.push(MapleIngestTarget {
            traces_endpoint: endpoint,
            ingest_key: key,
        }),
        (None, None) => {}
        _ => anyhow::bail!(
            "FLOW_CODEX_MAPLE_HOSTED_ENDPOINT and FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY must both be set"
        ),
    }

    let csv_endpoints =
        env_non_empty_with_store("FLOW_CODEX_MAPLE_TRACES_ENDPOINTS", &mut personal_env)
            .map(|raw| {
                raw.split(',')
                    .map(|value| value.trim().to_string())
                    .filter(|value| !value.is_empty())
                    .collect::<Vec<_>>()
            })
            .unwrap_or_default();
    let csv_keys = env_non_empty_with_store("FLOW_CODEX_MAPLE_INGEST_KEYS", &mut personal_env)
        .map(|raw| {
            raw.split(',')
                .map(|value| value.trim().to_string())
                .filter(|value| !value.is_empty())

View on GitHub (pinned to a747e741ae)

Solutions

  1. Set both FLOW_CODEX_MAPLE_HOSTED_ENDPOINT and FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY to non-empty values
  2. Or remove both variables to disable the hosted target
  3. Verify the variable names character-for-character (HOSTED, not LOCAL)

Example fix

// before
FLOW_CODEX_MAPLE_HOSTED_ENDPOINT=https://maple.example.com
# after (both set)
FLOW_CODEX_MAPLE_HOSTED_ENDPOINT=https://maple.example.com
FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY=sk-hosted-456
Defensive patterns

Strategy: validation

Validate before calling

fn hosted_maple_config_ok() -> bool {
    let ep = std::env::var("FLOW_CODEX_MAPLE_HOSTED_ENDPOINT").ok().filter(|v| !v.is_empty());
    let key = std::env::var("FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY").ok().filter(|v| !v.is_empty());
    ep.is_some() == key.is_some()
}
assert!(hosted_maple_config_ok(), "set both FLOW_CODEX_MAPLE_HOSTED_* vars or neither");

Type guard

fn paired_non_empty(a: Option<&str>, b: Option<&str>) -> Option<(&str, &str)> {
    match (a.filter(|v| !v.trim().is_empty()), b.filter(|v| !v.trim().is_empty())) {
        (Some(x), Some(y)) => Some((x, y)),
        _ => None,
    }
}

Try / catch

match telemetry::flush() {
    Err(e) if e.to_string().contains("HOSTED_ENDPOINT") => {
        eprintln!("{} — fix FLOW_CODEX_MAPLE_HOSTED_* pair in env", e);
        Err(e)
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling telemetry `status` or `flush` with exactly one of `FLOW_CODEX_MAPLE_HOSTED_ENDPOINT` / `FLOW_CODEX_MAPLE_HOSTED_INGEST_KEY` set (or one present but empty).

Common situations: Provisioning hosted Maple and copying only the endpoint into the environment; secrets manager exposing one key but not the other; casing/typo mismatches between the two variable names.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/350dae65db152587. Report an issue: GitHub.