risingwavelabs/risingwave · error · SinkError::Config

invalid compaction_type: {}, must be one of: {}, {}, {}, {}

Error message

invalid compaction_type: {}, must be one of: {}, {}, {}, {}

What it means

This is the FromStr parser for the `CompactionType` iceberg sink option. Only 'auto', 'full', 'small-files', and 'files-with-delete' (the ICEBERG_COMPACTION_TYPE_* constants) are accepted; any other compaction_type string fails with this config error at sink creation/validation time.

Source

Thrown at src/connector/src/sink/iceberg/config.rs:261

        match self {
            CompactionType::Auto => ICEBERG_COMPACTION_TYPE_AUTO,
            CompactionType::Full => ICEBERG_COMPACTION_TYPE_FULL,
            CompactionType::SmallFiles => ICEBERG_COMPACTION_TYPE_SMALL_FILES,
            CompactionType::FilesWithDelete => ICEBERG_COMPACTION_TYPE_FILES_WITH_DELETE,
        }
    }
}

impl std::str::FromStr for CompactionType {
    type Err = SinkError;

    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
        match s {
            ICEBERG_COMPACTION_TYPE_AUTO => Ok(CompactionType::Auto),
            ICEBERG_COMPACTION_TYPE_FULL => Ok(CompactionType::Full),
            ICEBERG_COMPACTION_TYPE_SMALL_FILES => Ok(CompactionType::SmallFiles),
            ICEBERG_COMPACTION_TYPE_FILES_WITH_DELETE => Ok(CompactionType::FilesWithDelete),
            _ => Err(SinkError::Config(anyhow!(format!(
                "invalid compaction_type: {}, must be one of: {}, {}, {}, {}",
                s,
                ICEBERG_COMPACTION_TYPE_AUTO,
                ICEBERG_COMPACTION_TYPE_FULL,
                ICEBERG_COMPACTION_TYPE_SMALL_FILES,
                ICEBERG_COMPACTION_TYPE_FILES_WITH_DELETE
            )))),
        }
    }
}

impl TryFrom<&str> for CompactionType {
    type Error = <Self as std::str::FromStr>::Err;

    fn try_from(value: &str) -> std::result::Result<Self, Self::Error> {
        value.parse()
    }
}

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Set compaction_type to exactly one of: auto, full, small-files, files-with-delete
  2. Remove the compaction_type option to use the default (auto)
  3. Match the literal constants in src/connector/src/sink/iceberg/config.rs if unsure of spelling
  4. Use kebab-case lowercase strings, no extra whitespace

Example fix

// before
WITH (connector = 'iceberg', compaction_type = 'Full')
// after
WITH (connector = 'iceberg', compaction_type = 'full')
Defensive patterns

Strategy: validation

Validate before calling

const VALID_COMPACTION_TYPES: [&str; 4] =
    ["auto", "full", "small-files", "files-with-delete"];
fn validate_compaction_type(t: &str) -> Result<(), String> {
    if VALID_COMPACTION_TYPES.contains(&t) {
        Ok(())
    } else {
        Err(format!(
            "invalid compaction_type: {}, must be one of: auto, full, small-files, files-with-delete",
            t
        ))
    }
}

Type guard

fn is_valid_compaction_type(s: &str) -> bool {
    matches!(s, "auto" | "full" | "small-files" | "files-with-delete")
}

Try / catch

match s.parse::<CompactionType>() {
    Ok(ct) => ct,
    Err(e) => return Err(e.context("compaction_type must be a lowercase kebab-case literal from docs")),
}

Prevention

When it happens

Trigger: A CREATE SINK ... WITH (connector='iceberg', compaction_type='...') uses a string outside the four accepted literals — e.g. 'none', ' Auto', 'full compaction', or a camel-case variant.

Common situations: Typos and casing mistakes when hand-writing WITH options; copying compaction option names from other iceberg tools; older option values that no longer exist after connector updates.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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