linera-io/linera-protocol · error · anyhow

Only supported scheme are http and https

Error message

Only supported scheme are http and https

What it means

`ensure_grpc_server_has_started` builds a tonic `Endpoint` for the health check and only understands two scheme strings: 'http' (plaintext gRPC) and 'https' (TLS with the linera test CERT_PEM). Any other scheme falls through to this bail. In-tree callers only pass 'http'/'https' (derived from `Network::Grpc`/`Network::Grpcs`), so hitting it means a custom caller invoked this public helper with a different string.

Source

Thrown at linera-service/src/cli_wrappers/local_net.rs:910

    /// Waits until the gRPC server at the given port responds as healthy.
    pub async fn ensure_grpc_server_has_started(
        nickname: &str,
        port: usize,
        scheme: &str,
    ) -> Result<()> {
        let endpoint = match scheme {
            "http" => Endpoint::new(format!("http://localhost:{port}"))
                .context("endpoint should always parse")?,
            "https" => {
                use linera_rpc::CERT_PEM;
                let certificate = tonic::transport::Certificate::from_pem(CERT_PEM);
                let tls_config = ClientTlsConfig::new().ca_certificate(certificate);
                Endpoint::new(format!("https://localhost:{port}"))
                    .context("endpoint should always parse")?
                    .tls_config(tls_config)?
            }
            _ => bail!("Only supported scheme are http and https"),
        };
        let connection = endpoint.connect_lazy();
        let mut client = HealthClient::new(connection);
        linera_base::time::timer::sleep(Duration::from_millis(100)).await;
        for i in 0..10 {
            linera_base::time::timer::sleep(Duration::from_millis(i * 500)).await;
            let result = client.check(HealthCheckRequest::default()).await;
            if result.is_ok() && result.unwrap().get_ref().status() == ServingStatus::Serving {
                info!(?port, "Successfully started {nickname}");
                return Ok(());
            } else {
                warn!("Waiting for {nickname} to start");
            }
        }
        bail!("Failed to start {nickname}");
    }

    async fn ensure_simple_server_has_started(

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Pass 'http' for plaintext gRPC or 'https' for the net's TLS setup
  2. When mapping a protocol enum, convert to one of the two scheme strings before calling the helper

Example fix

// before
LocalNet::ensure_grpc_server_has_started(&nickname, port, "grpc").await?;

// after
LocalNet::ensure_grpc_server_has_started(&nickname, port, "http").await?;
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED: [&str; 2] = ["http", "https"];
assert!(
    SUPPORTED.contains(&scheme),
    "scheme must be http or https, got {scheme}"
);

Type guard

fn is_supported_scheme(scheme: &str) -> bool {
    matches!(scheme, "http" | "https")
}

Prevention

When it happens

Trigger: Calling `LocalNet::ensure_grpc_server_has_started(nickname, port, scheme)` with a scheme like 'grpc', 'grpcs' or 'h2c' instead of 'http'/'https'.

Common situations: Custom test harnesses wrapping this public helper; refactors that add a new Network variant without mapping it to one of the two accepted scheme strings.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/1ff93bb729584218. Report an issue: GitHub.