Skip to content

fix: keep the command error result when a metrics tag cannot be built - #2681

Open
erichare wants to merge 1 commit into
mainfrom
fix/metrics-tags-invalid-clause
Open

erichare wants to merge 1 commit into
mainfrom
fix/metrics-tags-invalid-clause

Conversation

@erichare

@erichare erichare commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does:

A command with an invalid filter or sort clause now returns its error result through MCP. Before this change the MCP client received a bare JSON-RPC Internal error, and the command timer was never recorded for these requests on either API.

CommandProcessor already turns the clause failure into an error result. MeteredCommandProcessor then builds the filter and sort clauses a second time to choose the sort_type metric tag, and the same exception is thrown again from the success callback. That replaced the error result with a failed Uni. The HTTP API hid this because its exception mapper still produced the error body. The tag now falls back to NONE when a clause cannot be built, so the result and the timer are kept.

Which issue(s) this PR fixes:
Fixes #2680

Verification

The new test failed before the fix with Unsupported filter operator '$bogus' and passes after it. It checks that the processor returns the same error result and that the timer carries the filter error code and sort_type="NONE". The command below ran 125 tests with no failures or skips on JDK 25. I found the problem by calling find through MCP against DSE 6.9.21, but I have not repeated that call against this branch.

./mvnw -o -B -ntp test -DskipITs -Dfmt.skip=true -Dxml-format.skip=true \
  -Dsurefire.failIfNoSpecifiedTests=false -Dquarkus.http.test-port=19283 \
  '-Dtest=MeteredCommandProcessorTest,Mcp*Test,*Metrics*Test,!*IntegrationTest'

One open question. NONE is the tag for a request with an invalid clause because no sort was applied. A separate value such as INVALID would be more exact but adds a metric tag value.

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CLA Signed: DataStax CLA

MeteredCommandProcessor builds the filter and sort clauses again to choose
the sort_type tag. A clause the command already rejected throws again there,
which replaced the error result with a failed Uni and skipped the timer.
MCP reported that as a JSON-RPC internal error.
@erichare
erichare requested a review from a team as a code owner November 19, 2026 22:43
@github-actions

Copy link
Copy Markdown
Contributor

📉 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 57.12%
This PR 57.12%
Delta 🔴 -0.00%
⚠️ Coverage decreased

@github-actions

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 57.12% -0.01% 🍏
Files changed 0% ❌

File Coverage
MeteredCommandProcessor.java 0% -2.9% ❌

@github-actions

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 72.75%
This PR 72.74%
Delta 🔴 -0.01%
⚠️ Coverage decreased

@github-actions

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 72.74% 🍏
Files changed 100% 🍏

File Coverage
MeteredCommandProcessor.java 88.69% 🍏

@github-actions

Copy link
Copy Markdown
Contributor

📉 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 74.21%
This PR 74.20%
Delta 🔴 -0.01%
⚠️ Coverage decreased

@github-actions

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 74.2% 🍏
Files changed 100% 🍏

File Coverage
MeteredCommandProcessor.java 88.69% 🍏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: Return a tool error when a command fails during execution

1 participant