Skip to content

fix(native): Fix copy-paste bug in veloxQueryConfigOperation log message and add tests#27236

Merged
amitkdutta merged 1 commit intoprestodb:masterfrom
amitkdutta:export-D94800584
Mar 2, 2026
Merged

fix(native): Fix copy-paste bug in veloxQueryConfigOperation log message and add tests#27236
amitkdutta merged 1 commit intoprestodb:masterfrom
amitkdutta:export-D94800584

Conversation

@amitkdutta
Copy link
Copy Markdown
Contributor

@amitkdutta amitkdutta commented Mar 1, 2026

Summary:
Fix a copy-paste bug in PrestoServerOperations::veloxQueryConfigOperation() where the kSetProperty handler's response message incorrectly said "system property" instead of "velox query config property". This was caused by the function being copied from systemConfigOperation() without updating the log message.

Add comprehensive tests for the veloxQueryConfig operation endpoint:

  • URL path parsing for veloxQueryConfig/setProperty and veloxQueryConfig/getProperty
  • Getting an unknown property returns "" (unlike systemConfig which throws)
  • Getting a known registered property returns its value
  • Setting a property returns a message with correct "velox query config" wording
  • Round-trip set + get verification
  • Error cases: missing 'name' and missing 'value' parameters
== NO RELEASE NOTE ==

Summary by Sourcery

Fix the velox query config server operation messaging and extend coverage of its HTTP endpoint behavior.

Bug Fixes:

  • Correct the veloxQueryConfig setProperty response message to reference "velox query config" instead of "system" properties.

Tests:

  • Add URL path parsing tests for veloxQueryConfig setProperty and getProperty operations.
  • Add end-to-end tests for veloxQueryConfig behavior, including unknown property handling, value round-trips, and required parameter validation.

@amitkdutta amitkdutta requested review from a team as code owners March 1, 2026 00:21
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Mar 1, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 1, 2026

Reviewer's Guide

Fixes the veloxQueryConfig setProperty response message to correctly reference "velox query config" instead of "system property" and adds focused tests for the veloxQueryConfig operation endpoint, including URL parsing, success paths, and error handling.

Sequence diagram for veloxQueryConfig setProperty operation response

sequenceDiagram
  actor Admin
  participant HttpServer
  participant PrestoServerOperations
  participant SystemConfig

  Admin->>HttpServer: HTTP POST /v1/cluster/veloxQueryConfig/setProperty?name=n&value=v
  HttpServer->>PrestoServerOperations: veloxQueryConfigOperation(op)
  PrestoServerOperations->>SystemConfig: instance()
  SystemConfig-->>PrestoServerOperations: SystemConfig
  PrestoServerOperations->>SystemConfig: setProperty(name, value)
  SystemConfig-->>PrestoServerOperations: oldValue
  PrestoServerOperations-->>HttpServer: "Have set velox query config property '{}' to '{}'. Old value was '{}'." (formatted)
  HttpServer-->>Admin: HTTP 200 with updated message
Loading

Class diagram for veloxQueryConfig operation handling

classDiagram
  class PrestoServerOperations {
    +veloxQueryConfigOperation(op: ServerOperation) string
  }

  class ServerOperation {
    +target: string
    +action: string
    +params: map
    +targetString(target: int) string
    +actionString(action: int) string
  }

  class SystemConfig {
    -instance_: SystemConfig
    +instance() SystemConfig
    +setProperty(name: string, value: string) string
    +getProperty(name: string, defaultValue: string) string
  }

  PrestoServerOperations --> ServerOperation : uses
  PrestoServerOperations --> SystemConfig : updates config
Loading

File-Level Changes

Change Details Files
Corrected the veloxQueryConfig setProperty success message to reference velox query config properties instead of system properties.
  • Updated the formatted response string for veloxQueryConfigOperation kSetProperty to say "Have set velox query config property '{}' to '{}'" instead of "Have set system property value '{}' to '{}'" while keeping the rest of the format and behavior intact.
presto-native-execution/presto_cpp/main/PrestoServerOperations.cpp
Expanded ServerOperation tests to cover veloxQueryConfig operations, including URL parsing, behavior differences vs systemConfig, and error cases.
  • Extended buildServerOpFromHttpMsgPath tests to assert correct ServerOperation target/action for veloxQueryConfig/setProperty and veloxQueryConfig/getProperty paths.
  • Added registration/setup helpers for mutable configs and filesystem required by velox query config operations.
  • Introduced veloxQueryConfigEndpoint test that verifies unknown property handling returns "" instead of throwing, known property retrieval matches hardware_concurrency, setProperty success messages contain the expected "velox query config" wording and echo name/value, round-trip set+get behavior for a config key, and error handling when required query parameters 'name' or 'value' are missing.
presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="presto-native-execution/presto_cpp/main/tests/ServerOperationTest.cpp" line_range="279-286" />
<code_context>
+      &httpMessage);
+  EXPECT_EQ(std::stoi(getPropertyResponse), folly::hardware_concurrency());
+
+  // Setting a registered property returns a message with "velox query config"
+  // wording (verifying the copy-paste bug fix from systemConfigOperation).
+  httpMessage.setQueryParam("name", "shutdown-onset-sec");
+  httpMessage.setQueryParam("value", "42");
+  auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
+      {.target = ServerOperation::Target::kVeloxQueryConfig,
+       .action = ServerOperation::Action::kSetProperty},
+      &httpMessage);
+  EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
+  EXPECT_NE(
+      setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
+  EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
+
+  // Verify the property was set by reading it back.
</code_context>
<issue_to_address>
**suggestion (testing):** Also assert that the response no longer contains the old "system property" wording

To better protect against regressions of the original copy‑paste bug, add a negative assertion that the `setProperty` response does not contain "system property", e.g.:

```cpp
EXPECT_EQ(
    setPropertyResponse.find("system property"),
    std::string::npos);
```

This complements the positive check for "velox query config" and guards against reintroducing the old wording.

```suggestion
  auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
      {.target = ServerOperation::Target::kVeloxQueryConfig,
       .action = ServerOperation::Action::kSetProperty},
      &httpMessage);
  EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
  EXPECT_NE(
      setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
  EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
  EXPECT_EQ(
      setPropertyResponse.find("system property"), std::string::npos);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +279 to +286
auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
{.target = ServerOperation::Target::kVeloxQueryConfig,
.action = ServerOperation::Action::kSetProperty},
&httpMessage);
EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
EXPECT_NE(
setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Also assert that the response no longer contains the old "system property" wording

To better protect against regressions of the original copy‑paste bug, add a negative assertion that the setProperty response does not contain "system property", e.g.:

EXPECT_EQ(
    setPropertyResponse.find("system property"),
    std::string::npos);

This complements the positive check for "velox query config" and guards against reintroducing the old wording.

Suggested change
auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
{.target = ServerOperation::Target::kVeloxQueryConfig,
.action = ServerOperation::Action::kSetProperty},
&httpMessage);
EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
EXPECT_NE(
setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
auto setPropertyResponse = serverOperation.veloxQueryConfigOperation(
{.target = ServerOperation::Target::kVeloxQueryConfig,
.action = ServerOperation::Action::kSetProperty},
&httpMessage);
EXPECT_NE(setPropertyResponse.find("velox query config"), std::string::npos);
EXPECT_NE(
setPropertyResponse.find("shutdown-onset-sec"), std::string::npos);
EXPECT_NE(setPropertyResponse.find("42"), std::string::npos);
EXPECT_EQ(
setPropertyResponse.find("system property"), std::string::npos);

…age and add tests (prestodb#27236)

Summary:

Fix a copy-paste bug in `PrestoServerOperations::veloxQueryConfigOperation()` where the `kSetProperty` handler's response message incorrectly said "system property" instead of "velox query config property". This was caused by the function being copied from `systemConfigOperation()` without updating the log message.

Add comprehensive tests for the `veloxQueryConfig` operation endpoint:
- URL path parsing for veloxQueryConfig/setProperty and veloxQueryConfig/getProperty
- Getting an unknown property returns "<default>" (unlike systemConfig which throws)
- Getting a known registered property returns its value
- Setting a property returns a message with correct "velox query config" wording
- Round-trip set + get verification
- Error cases: missing 'name' and missing 'value' parameters

Differential Revision: D94800584
@amitkdutta amitkdutta merged commit 176641a into prestodb:master Mar 2, 2026
111 of 114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants