8000 fix: handle missing 'connector' field in WITH clause with CONNECTION (#21691) by github-actions[bot] · Pull Request #21694 · risingwavelabs/risingwave · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: handle missing 'connector' field in WITH clause with CONNECTION (#21691) #21694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

github-actions[bot]
Copy link
Contributor
@github-actions github-actions bot commented May 4, 2025

Cherry picking #21691 onto branch release-2.3,

This PR/issue was created by cherry-pick action from commit f837e37.,

@github-actions github-actions bot added the cherry-pick The PR is to cherry-pick new commits to an old release branch. label May 4, 2025
@github-actions github-actions bot requested a review from tabVersion May 4, 2025 12:43
@tabVersion tabVersion requested review from lmatz, kwannoel and Copilot May 4, 2025 12:53
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR cherry-picks a fix to safely handle cases where the 'connector' field is missing in the WITH clause when a connection is used. The changes replace the use of unwrap with a safe pattern matching that returns an appropriate error in both source and sink creation handlers.

  • In src/frontend/src/handler/create_source.rs, unwrap() is replaced with a let else pattern using UPSTREAM_SOURCE_KEY.
  • In src/frontend/src/handler/create_sink.rs, unwrap() is replaced similarly with a let else pattern using CONNECTOR_TYPE_KEY.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/frontend/src/handler/create_source.rs Uses safe extraction for the connector field, returning an error if missing instead of panicking.
src/frontend/src/handler/create_sink.rs Applies safe extraction for the connector field from resolved_with_options to prevent runtime panic.
Files not reviewed (1)
  • e2e_test/source_inline/connection/ddl.slt: Language not supported

@@ -832,7 +832,12 @@ pub async fn bind_create_source_or_table_with_connector(

// if not using connection, we don't need to check connector match connection type
if !matches!(connection_type, PbConnectionType::Unspecified) {
let connector = with_properties.get_connector().unwrap();
let Some(connector) = with_properties.get_connector() else {
Copy link
Preview
Copilot AI May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing unwrap() with pattern matching avoids a potential runtime panic when the connector field is missing. The use of a proper error message with UPSTREAM_SOURCE_KEY improves error handling.

Copilot uses AI. Check for mistakes.

Comment on lines +117 to +122
let Some(connector) = resolved_with_options.get_connector() else {
return Err(RwError::from(ErrorCode::ProtocolError(format!(
"missing field '{}' in WITH clause",
CONNECTOR_TYPE_KEY
))));
};
Copy link
Preview
Copilot AI May 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a safe extraction pattern rather than unwrap() prevents a possible panic due to a missing connector field, with an explicit error message referencing CON 8000 NECTOR_TYPE_KEY.

Suggested change
let Some(connector) = resolved_with_options.get_connector() else {
return Err(RwError::from(ErrorCode::ProtocolError(format!(
"missing field '{}' in WITH clause",
CONNECTOR_TYPE_KEY
))));
};
let connector = resolved_with_options
.get_connector()
.ok_or_else(|| {
RwError::from(ErrorCode::ProtocolError(format!(
"missing field '{}' in WITH clause",
CONNECTOR_TYPE_KEY
)))
})?;

Copilot uses AI. Check for mistakes.

@lmatz lmatz added this pull request to the merge queue May 6, 2025
Merged via the queue into release-2.3 with commit 697256a May 6, 2025
24 checks passed
@lmatz lmatz deleted the auto-release-2.3-f837e37698b87ffde0b3510e5e66a5f35163531a-1746362595 branch May 6, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick The PR is to cherry-pick new commits to an old release branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0