risingwavelabs/risingwave · error · ConnectorError

test source only available at test

Error message

test source only available at test

What it means

The test source is a fake connector meant only for unit/e2e tests. Its properties parser intentionally fails with this error when compiled outside test/madsim configurations (cfg!(any(madsim,test)) is false), preventing production binaries from constructing TestSourceProperties.

Source

Thrown at src/connector/src/source/test_source.rs:137

pub const TEST_CONNECTOR: &str = "test";

#[derive(Clone, Debug, Default, WithOptions)]
pub struct TestSourceProperties {
    properties: BTreeMap<String, String>,
}

impl EnforceSecret for TestSourceProperties {}

impl TryFromBTreeMap for TestSourceProperties {
    fn try_from_btreemap(
        props: BTreeMap<String, String>,
        _deny_unknown_fields: bool,
    ) -> ConnectorResult<Self> {
        if cfg!(any(madsim, test)) {
            Ok(TestSourceProperties { properties: props })
        } else {
            bail!("test source only available at test")
        }
    }
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TestSourceSplit {
    pub id: SplitId,
    pub properties: HashMap<String, String>,
    pub offset: String,
}

impl SplitMetaData for TestSourceSplit {
    fn id(&self) -> SplitId {
        self.id.clone()
    }

    fn encode_to_json(&self) -> JsonbVal {
        serde_json::to_value(self.clone()).unwrap().into()

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Remove connector='test' from the source definition and use a real connector (kafka, pulsar, etc.)
  2. Rebuild/run under madsim or test cfg if you genuinely need the test source (i.e. within the test harness)
  3. Switch to a development profile binary that enables the test source feature

Example fix

// before
WITH (connector = 'test')
// after
WITH (connector = 'kafka', properties.bootstrap.server = '...', topic = '...')
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.RW_TEST_MODE && connector === 'test') {
  throw new Error("connector 'test' is only available in test builds");
}

Type guard

const isTestConnectorAllowed = () => typeof __TEST_BUILD__ !== 'undefined' && __TEST_BUILD__;

Try / catch

try { createSource({connector:'test'}); } catch (e) { if (String(e).includes('test source only available at test')) { useRealConnectorInstead(); } else { throw e; } }

Prevention

When it happens

Trigger: Calling TestSourceProperties::try_from_btreemap in a release (non-madsim, non-test) build, e.g. a user attempting `CREATE SOURCE ... WITH connector='test'` against a production risingwave binary.

Common situations: Copy-pasting test SQL from the e2e test suite into a production cluster, or running a debug tool linked against the connector crate in release mode while trying to use the test connector.

Related errors


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