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

Percent-encode invalid flint index characters #215

Merged
merged 5 commits into from
Jan 9, 2024

Conversation

seankao-az
Copy link
Collaborator

@seankao-az seankao-az commented Jan 9, 2024

Description

Handle special characters when generating Flint index name by percent-encoding the invalid OpenSearch index name characters.

Issues Resolved

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Sean Kao <[email protected]>
StringBuilder builder = new StringBuilder(indexName.length());
for (char ch : indexName.toCharArray()) {
if (charsToEncode.contains(ch)) {
builder.append("%").append(String.format("%02X", (int) ch));
Copy link
Collaborator Author

@seankao-az seankao-az Jan 9, 2024

Choose a reason for hiding this comment

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

slightly prefer this over builder.append(String.format("%%%02X", (int) ch)). suggestions are welcome

edit: did a bit more reading and changed my mind

Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

Copy link
Collaborator

@noCharger noCharger left a comment

Choose a reason for hiding this comment

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

Lgtm

@dai-chen
Copy link
Collaborator

dai-chen commented Jan 9, 2024

FYI, the main branch version is already bumped to 0.2. You can add backport label as needed.

Signed-off-by: Sean Kao <[email protected]>
@seankao-az
Copy link
Collaborator Author

@dai-chen I couldn't merge nor add label 😞

@dai-chen dai-chen added enhancement New feature or request 0.2 backport 0.1 labels Jan 9, 2024
@dai-chen
Copy link
Collaborator

dai-chen commented Jan 9, 2024

@dai-chen I couldn't merge nor add label 😞

No worries. Let me do it. :)

@dai-chen dai-chen merged commit 3528b66 into opensearch-project:main Jan 9, 2024
3 of 7 checks passed
@opensearch-trigger-bot
Copy link

The backport to 0.1 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/opensearch-spark/backport-0.1 0.1
# Navigate to the new working tree
pushd ../.worktrees/opensearch-spark/backport-0.1
# Create a new branch
git switch --create backport/backport-215-to-0.1
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3528b6660f7f1ddb2fbb9d0af8a0748e545424e3
# Push it to GitHub
git push --set-upstream origin backport/backport-215-to-0.1
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/opensearch-spark/backport-0.1

Then, create a pull request where the base branch is 0.1 and the compare/head branch is backport/backport-215-to-0.1.

@dai-chen
Copy link
Collaborator

dai-chen commented Jan 9, 2024

@seankao-az Auto backport failed. Could you check if any conflict and publish backport PR manually?

seankao-az added a commit to seankao-az/opensearch-spark that referenced this pull request Jan 9, 2024
* percent-encode invalid flint index characters

Signed-off-by: Sean Kao <[email protected]>

* formatting

Signed-off-by: Sean Kao <[email protected]>

* move encoding logic to FlintOpenSearchClient

Signed-off-by: Sean Kao <[email protected]>

* minor arg fix and string format fix

Signed-off-by: Sean Kao <[email protected]>

* fix import order

Signed-off-by: Sean Kao <[email protected]>

---------

Signed-off-by: Sean Kao <[email protected]>
(cherry picked from commit 3528b66)
dai-chen pushed a commit that referenced this pull request Jan 9, 2024
* percent-encode invalid flint index characters

Signed-off-by: Sean Kao <[email protected]>

* formatting

Signed-off-by: Sean Kao <[email protected]>

* move encoding logic to FlintOpenSearchClient

Signed-off-by: Sean Kao <[email protected]>

* minor arg fix and string format fix

Signed-off-by: Sean Kao <[email protected]>

* fix import order

Signed-off-by: Sean Kao <[email protected]>

---------

Signed-off-by: Sean Kao <[email protected]>
(cherry picked from commit 3528b66)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants