risingwavelabs/risingwave · error · ConnectorError

Invalid field: {}, allowed fields: {:?}

Error message

Invalid field: {}, allowed fields: {:?}

What it means

Strict validation of the connection properties when converting an ElasticsearchConnection into ElasticsearchOpenSearchConfig. Only `url`, `username`, and `password` are permitted; any other key in the connection's properties map causes this error, preventing silently ignored options.

Source

Thrown at src/connector/src/sink/elasticsearch_opensearch/elasticsearch_opensearch_config.rs:146

}

fn default_batch_size_kb() -> usize {
    5 * 1024
}

fn default_concurrent_requests() -> usize {
    1024
}

impl TryFrom<&ElasticsearchConnection> for ElasticSearchOpenSearchConfig {
    type Error = ConnectorError;

    fn try_from(value: &ElasticsearchConnection) -> std::result::Result<Self, Self::Error> {
        let allowed_fields: HashSet<&str> = hashset!["url", "username", "password"]; // from ElasticsearchOpenSearchConfig

        for k in value.0.keys() {
            if !allowed_fields.contains(k.as_str()) {
                return Err(ConnectorError::from(anyhow!(
                    "Invalid field: {}, allowed fields: {:?}",
                    k,
                    allowed_fields
                )));
            }
        }

        let config = serde_json::from_value::<ElasticSearchOpenSearchConfig>(
            serde_json::to_value(value.0.clone()).unwrap(),
        )
        .map_err(|e| SinkError::Config(anyhow!(e)))?;
        Ok(config)
    }
}

impl ElasticSearchConfig {
    pub fn from_btreemap(properties: BTreeMap<String, String>) -> Result<Self> {
        let config = serde_json::from_value::<ElasticSearchConfig>(

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Remove unknown keys from the connection definition; keep only url/username/password.
  2. Move sink-specific options (index, primary_key, routing_column, delimiter) into the sink's WITH clause instead.
  3. Check key spelling against the allowed set {url, username, password}.

Example fix

// before
CREATE CONNECTION es_conn WITH (
  TYPE = ELASTICSEARCH,
  url = 'http://localhost:9200',
  index = 'my-index'
)
// after
CREATE CONNECTION es_conn WITH (
  TYPE = ELASTICSEARCH,
  url = 'http://localhost:9200'
)
-- put 'index' in the sink WITH clause instead
Defensive patterns

Strategy: validation

Validate before calling

-- before CREATE CONNECTION
-- allowed keys are exactly: url, username, password
CREATE CONNECTION es_conn WITH (TYPE = ELASTICSEARCH, url = 'http://localhost:9200');

Try / catch

match err { ConnectorError(e) if e.to_string().contains("Invalid field") => move_option_to_sink_with_clause(e), _ => return Err(err) }

Prevention

When it happens

Trigger: Defining an ES/OpenSearch connection (CREATE CONNECTION ... TYPE ELASTICSEARCH) whose properties include any key outside {url, username, password}, e.g. `index`, `delimiter`, or `primary_key` mistakenly placed on the connection instead of the sink.

Common situations: Copying sink-level WITH options into the connection definition; typos like `Username`; leftover options from a different connector type.

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/a332210397d0bb01. Report an issue: GitHub.