warpdotdev/warp · error · anyhow::Error

failed to create API key

Error message

failed to create API key

What it means

Raised when the `generateApiKey` GraphQL mutation returns `GenerateApiKeyResult::Unknown`: the server responded, but the payload matched neither the success output nor a recognized user-facing error variant. It is the generic fallback after structured server errors are handled, and usually indicates client/server schema or version skew.

Source

Thrown at app/src/ai/agent_sdk/api_key.rs:115

            async move {
                let json_output = args.json_output;
                let expires_at = expires_at_from_args(args.expiration)?;
                let agent_uid = args.agent_uid.map(cynic::Id::new);
                let result = auth_client
                    .create_api_key(args.name, None, agent_uid, expires_at)
                    .await?;
                let result = match result {
                    GenerateApiKeyResult::GenerateApiKeyOutput(output) => CreatedApiKeyInfo {
                        raw_api_key: output.raw_api_key,
                        api_key: ApiKeyInfo::from(output.api_key),
                    },
                    GenerateApiKeyResult::UserFacingError(e) => {
                        return Err(anyhow!(
                            warp_graphql::client::get_user_facing_error_message(e)
                        ));
                    }
                    GenerateApiKeyResult::Unknown => {
                        return Err(anyhow!("failed to create API key"));
                    }
                };
                print_created_api_key(result, output_format, json_output)?;
                Ok(())
            },
            |_, result: Result<()>, ctx| finish_command(result, ctx),
        );
    }

    fn expire(
        &self,
        output_format: OutputFormat,
        args: ExpireApiKeyArgs,
        ctx: &mut ModelContext<Self>,
    ) {
        let key_identifier = args.key_uid;
        let force = args.force;
        let json_output = args.json_output;

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. Retry the command once — transient gateway/proxy interference can produce Unknown
  2. Update the Warp CLI/client to a build whose schema matches the server
  3. Verify the network path (no intercepting proxy) and that auth is valid; re-login if the session expired
  4. If it persists, check server-side status/logs: the raw payload matched no known variant
Defensive patterns

Strategy: retry

Try / catch

match auth_client.create_api_key(name, None, agent_uid, expires_at).await? {
    GenerateApiKeyResult::GenerateApiKeyOutput(output) => Ok(output),
    GenerateApiKeyResult::UserFacingError(e) =>
        Err(anyhow!(warp_graphql::client::get_user_facing_error_message(e))),
    GenerateApiKeyResult::Unknown => {
        // Indeterminate response: safe to retry create (server enforces name uniqueness)
        // but alert on repetition — sustained Unknown means client/server schema skew.
        retry_or_report("unrecognized generateApiKey response; update client and retry")
    }
}

Prevention

When it happens

Trigger: Running `warp api-key create ...`; `auth_client.create_api_key(...)` deserializes to the Unknown variant because of an unexpected response shape, a new unrecognized server error code, or an intermediary (proxy/gateway) altering the response.

Common situations: Client build older than the server's GraphQL schema; staging vs production endpoints; intercepting proxies returning HTML error pages; server incidents producing unrecognized payloads.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/486fbb0e1dd2dbc0. Report an issue: GitHub.