risingwavelabs/risingwave · error · SinkError::GooglePubSub

Google Pub/Sub sink error: missing value to publish

Error message

Google Pub/Sub sink error: missing value to publish

What it means

During `write_one`, the sink expects to extract a value from the event to publish as the message body, but the value slot was `None`. The sink refuses to publish an empty/absent payload and returns this error instead.

Source

Thrown at src/connector/src/sink/google_pubsub.rs:336

}

impl FormattedSink for GooglePubSubPayloadWriter<'_> {
    type K = String;
    type V = Vec<u8>;

    async fn write_one(&mut self, k: Option<Self::K>, v: Option<Self::V>) -> Result<()> {
        let ordering_key = k.unwrap_or_default();
        match v {
            Some(data) => {
                let msg = PubsubMessage {
                    data,
                    ordering_key,
                    ..Default::default()
                };
                self.message_vec.push(msg);
                Ok(())
            }
            None => Err(SinkError::GooglePubSub(anyhow!(
                "Google Pub/Sub sink error: missing value to publish"
            ))),
        }
    }
}

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Ensure the payload column is NOT NULL in the source/materialized view
  2. Filter out NULL rows before the sink (e.g. WHERE payload IS NOT NULL in the MV)
  3. Use an appropriate encoder/format that always produces a value for the event type
  4. If deletes produce null payloads, enable the sink's append-only/ignore-delete handling

Example fix

// before
CREATE MATERIALIZED VIEW mv AS SELECT nullable_payload FROM src;
// after
CREATE MATERIALIZED VIEW mv AS SELECT nullable_payload FROM src WHERE nullable_payload IS NOT NULL;
Defensive patterns

Strategy: validation

Validate before calling

CREATE MATERIALIZED VIEW mv AS
SELECT payload FROM src WHERE payload IS NOT NULL;

Try / catch

match sink.write_one(event).await {
    Err(e) if e.to_string().contains("missing value to publish") => {
        log::warn!("skipping null-payload event");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Writing a row/event where the payload-producing expression yields None — e.g. a NULL value in a single-column payload schema, or a formatting step that produced no value.

Common situations: Inserting NULL into the payload column of an HTTP/Pub/Sub style sink; upstream Debezium/encoder emitting null for deletes in non-append-only mode; schema mismatch between the materialized view and sink expectation.

Related errors


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