{"record":{"id":"218cc640467dae14","repo":"warpdotdev/warp","slug":"unexpected-argument-environment-found","errorCode":null,"errorMessage":"unexpected argument '--environment' found","messagePattern":"unexpected argument '--environment' found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/mod.rs","lineNumber":269,"sourceCode":"        ResolveSkillError::ParseFailed { path, message } => {\n            format!(\"Failed to parse skill file {}: {message}\", path.display())\n        }\n        ResolveSkillError::CloneFailed { org, repo, message } => {\n            format!(\"Failed to clone repository '{org}/{repo}': {message}\")\n        }\n    }\n}\n\n/// Run the agent with the provided command.\nfn run_agent(\n    ctx: &mut AppContext,\n    global_options: GlobalOptions,\n    command: AgentCommand,\n) -> anyhow::Result<()> {\n    match command {\n        AgentCommand::Run(args) => {\n            if args.environment.is_some() && !FeatureFlag::CloudEnvironments.is_enabled() {\n                return Err(anyhow::anyhow!(\"unexpected argument '--environment' found\"));\n            }\n            if args.conversation.is_some() && !FeatureFlag::CloudConversations.is_enabled() {\n                return Err(anyhow::anyhow!(\n                    \"unexpected argument '--conversation' found\"\n                ));\n            }\n            if args.skill.is_some() && !FeatureFlag::OzPlatformSkills.is_enabled() {\n                return Err(anyhow::anyhow!(\"unexpected argument '--skill' found\"));\n            }\n            if args.harness != Harness::Oz && !FeatureFlag::AgentHarness.is_enabled() {\n                return Err(anyhow::anyhow!(\"unexpected argument '--harness' found\"));\n            }\n            if args.harness == Harness::OpenCode {\n                return Err(anyhow::anyhow!(\n                    \"The opencode harness is only supported for local child agent launches.\"\n                ));\n            }\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/mod.rs#L251-L287","documentation":"Thrown in run_agent for AgentCommand::Run (mod.rs:269): clap accepted `--environment` (it is in the grammar), but FeatureFlag::CloudEnvironments is disabled, so the handler rejects it with an error that mimics clap's 'unexpected argument' message. The design hides optional cloud-environment targeting when the feature is gated, making the flag look unknown rather than merely disabled.","triggerScenarios":"Running `agent run --environment <id/prompt>` where FeatureFlag::CloudEnvironments.is_enabled() == false. The value parses into args.environment before the gate runs; only the flag state triggers the error.","commonSituations":"Pinning agent runs to a specific cloud environment on a build where cloud environments are gated; templates/playbooks written on dogfood builds; after a Warp downgrade that dropped the feature.","solutions":["Drop `--environment` and run against the default environment","Use a build/account where CloudEnvironments is enabled, or update to a version where it shipped to your channel","As a Warp developer, override the flag or add FeatureFlag::CloudEnvironments to DOGFOOD_FLAGS and rebuild"],"exampleFix":"# before\n$ oz agent run --environment dev-box \"fix the flaky test\"\nError: unexpected argument '--environment' found\n\n# after\n$ oz agent run \"fix the flaky test\"","handlingStrategy":"validation","validationCode":"// Rust callers building AgentCommand::Run:\nif args.environment.is_some() {\n    anyhow::ensure!(\n        FeatureFlag::CloudEnvironments.is_enabled(),\n        \"--environment requires CloudEnvironments\"\n    );\n}","typeGuard":"pub fn can_target_environment(args: &AgentRunArgs) -> bool {\n    args.environment.is_none() || FeatureFlag::CloudEnvironments.is_enabled()\n}","tryCatchPattern":"match run_agent(ctx, opts, cmd) {\n    Err(e) if e.to_string().contains(\"unexpected argument '--environment'\") => {\n        // retry without --environment against the default environment\n    }\n    result => result?,\n}","preventionTips":["Make optional flags data-driven: only append --environment when the probe says it is available","Do not treat clap-shaped 'unexpected argument' from this layer as a syntax bug - it is a feature gate","Keep a single feature-probe helper for all gated agent-run flags"],"tags":["cli","feature-flags","cloud-environments","rust","clap"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}