Skip to content
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

Fix the issue on REST API primaryPath encoding (Quarkus Reactive REST) #2658

Merged
merged 9 commits into from
Jul 20, 2023

Conversation

tatu-at-datastax
Copy link
Collaborator

@tatu-at-datastax tatu-at-datastax commented Jul 5, 2023

What this PR does:

Adds testing, fix, for the issue where primary key segment contains encoded / as part of key; this must not be used as segment separator but included in segment. DropWizard (SGv1/REST) handled this correctly, Quarkus seems to have problems.

Also updates Quarkus to version 3.2.1 which has fix for:

quarkusio/quarkus#34586

which is the underlying bug.

Which issue(s) this PR fixes:
N/A

Checklist

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

@@ -216,7 +218,7 @@ protected String endpointPathForRowGetWith(String ksName, String tableName) {
protected String endpointPathForRowByPK(String ksName, String tableName, Object... primaryKeys) {
StringBuilder sb = new StringBuilder(String.format("/v2/keyspaces/%s/%s", ksName, tableName));
for (Object key : primaryKeys) {
sb.append('/').append(key);
sb.append('/').append(URLEncoder.encode(key.toString(), StandardCharsets.UTF_8));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this fix un-encoded / would be added leading to (true) failures.

@tatu-at-datastax
Copy link
Collaborator Author

Blocked by now-reported bug:

quarkusio/quarkus#34586

@tatu-at-datastax
Copy link
Collaborator Author

Underlying Quarkus bug fixed via quarkusio/quarkus#34809 -- we'll see which release will include the fix to resolve issue at our end.

@tatu-at-datastax tatu-at-datastax marked this pull request as ready for review July 20, 2023 00:40
@tatu-at-datastax tatu-at-datastax requested a review from a team as a code owner July 20, 2023 00:40
@@ -2631,7 +2631,12 @@ public void escapedChar() {
.header(HttpConstants.AUTHENTICATION_TOKEN_HEADER_NAME, getAuthToken())
.queryParam("raw", true)
.when()
.get(BASE_PATH + "/{document-id}/a%5C.b", DEFAULT_NAMESPACE, DEFAULT_COLLECTION, id)
.get(
BASE_PATH + "/{document-id}/{leaf}",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Earlier code was trying to pre-encode path but it really needs to be left to framework to do with template.
This may have "worked" with conjuction with bug Quarkus 3.2.1 fixed but is incorrect, leading to double-encoding by caller and then mismatching on server side.

DEFAULT_NAMESPACE,
DEFAULT_COLLECTION,
id,
"a\\.b")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case need first doubling for Java compiler, but then \ itself handled by Docs API server side to avoid interpreting following . as path separator.

@tatu-at-datastax tatu-at-datastax changed the title Fix the issue on REST API primaryPath encoding (Quarkus vs DropWizard) Fix the issue on REST API primaryPath encoding (Quarkus Reactive REST) Jul 20, 2023
@tatu-at-datastax tatu-at-datastax merged commit bd7382e into main Jul 20, 2023
@tatu-at-datastax tatu-at-datastax deleted the v2/tatu/c2-2769-primary-key-encoding branch July 20, 2023 21:06
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.

2 participants