risingwavelabs/risingwave · error

expect a string or a json array for privatelink.endpoint, bu

Error message

expect a string or a json array for privatelink.endpoint, but got {:?}

What it means

In `handle_privatelink_endpoint` (src/connector/src/source/kafka/private_link.rs:226), RisingWave parses the `privatelink.endpoint` WITH clause option as JSON. It accepts either a plain string (one endpoint used for all brokers) or a JSON array of `{"host": ...}` objects (one per broker/AZ). If the parsed value is neither a JSON string nor an array (e.g. a number, boolean, or object), the connector bails with this error because there is no defined way to map the value onto broker addresses.

Source

Thrown at src/connector/src/source/kafka/private_link.rs:226

                        "expected JSON in the form {{\"host\": \"endpoint url\"}}, but got {}",
                        v
                    )
                })
            })
            .collect::<Result<Vec<_>, _>>()?;
        for ((link, broker), endpoint) in link_targets
            .iter()
            .zip_eq_fast(broker_addrs.iter())
            .zip_eq_fast(endpoint_list.iter())
        {
            // rewrite the broker address to endpoint:port
            broker_rewrite_map.insert(
                broker.to_string(),
                format!("{}:{}", endpoint.host, link.port),
            );
        }
    } else {
        bail!(
            "expect a string or a json array for privatelink.endpoint, but got {:?}",
            endpoint
        )
    }

    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_handle_privatelink_endpoint() {
        let endpoint = "some_url"; // raw string
        let link_targets = vec![
            AwsPrivateLinkItem {
                az_id: None,

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Set `privatelink.endpoint` to a plain endpoint string, e.g. `privatelink.endpoint = 'vpce-xxxx.s3.ap-southeast-1.vpce.amazonaws.com'`.
  2. If per-broker endpoints are needed, use a JSON array of {"host": "..."} objects, e.g. `privatelink.endpoint = '[{"host":"vpce-0a11"},{"host":"vpce-0a22"}]'` — the array length must match the broker count.
  3. Check that the value is not accidentally a bare number/boolean (quote it in SQL so it stays a string).

Example fix

// before (WITH option)
privatelink.endpoint = '12345'            -- parsed as JSON number -> error
// after
privatelink.endpoint = 'my-vpce-endpoint.example.com'  -- plain string
Defensive patterns

Strategy: validation

Validate before calling

// Validate the privatelink.endpoint value before CREATE SOURCE
let v: serde_json::Value = serde_json::from_str(raw)
    .unwrap_or(serde_json::Value::String(raw.to_string()));
let valid = v.is_string()
    || (v.is_array()
        && v.as_array().unwrap().iter().all(|item| {
            item.get("host").map_or(false, |h| h.is_string())
        }));
assert!(valid, "privatelink.endpoint must be a string or an array of {{\"host\": \"...\"}}");

Type guard

fn is_valid_privatelink_endpoint(v: &serde_json::Value) -> bool {
    v.is_string()
        || (v.is_array()
            && v.as_array().unwrap().iter().all(|i| i.get("host").map_or(false, |h| h.is_string())))
}

Prevention

When it happens

Trigger: Creating a Kafka source with privatelink options where the `privatelink.endpoint` value parses as a JSON type other than string or array — e.g. `privatelink.endpoint='123'`, `'true'`, or a JSON object `'"host":"x"'` that was not wrapped in an array.

Common situations: Users typo the endpoint value without quotes, paste a host:port where a number port gets parsed as a JSON number, or supply a single JSON object instead of an array of objects when specifying per-AZ endpoints.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/668cef65c6c0cb5d. Report an issue: GitHub.