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 upsert too long id #103399

Merged
merged 5 commits into from Jan 17, 2024
Merged

Fix upsert too long id #103399

merged 5 commits into from Jan 17, 2024

Conversation

wdongyu
Copy link
Contributor

@wdongyu wdongyu commented Dec 13, 2023

Closes #102981

@elasticsearchmachine elasticsearchmachine added v8.13.0 needs:triage Requires assignment of a team area label external-contributor Pull request authored by a developer outside the Elasticsearch team labels Dec 13, 2023
@pxsalehi pxsalehi added :Search/Search Search-related issues that do not fall into other categories and removed needs:triage Requires assignment of a team area label labels Dec 18, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Dec 18, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@pxsalehi pxsalehi added the >bug label Dec 18, 2023
@@ -495,6 +496,27 @@ public void testToValidateUpsertRequestWithVersion() {
assertThat(updateRequest.validate().validationErrors(), contains("can't provide version in upsert request"));
}

public void testUpdatingRejectsLongIds() {
String id = randomAlphaOfLength(511);

Choose a reason for hiding this comment

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

@wdongyu this can be looped. code isnt compact here and DRY/iteration can be followed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bohemia420 just follow the testIndexingRejectsLongIds func in IndexRequest, ok to be looped

request.doc("{}", XContentType.JSON);
validate = request.validate();
assertThat(validate, notNullValue());
assertThat(validate.getMessage(), containsString("id [" + id + "] is too long, must be no longer than 512 bytes but was: 513"));

Choose a reason for hiding this comment

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

@wdongyu 512, 513 are hardcoded and repeated. 512 can be a maxlen constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👌

@bohemia420
Copy link

@wdongyu there may be no need to have 2 commits - kindly squash into 1.

@bohemia420
Copy link

is there any nomenclature for git branching? can we name it better than wdongyu:fix_upsert_too_long_id, maybe as bug-103399-wdongyu? @wdongyu

@benwtrent
Copy link
Member

@wdongyu there may be no need to have 2 commits - kindly squash into 1.

No, don't do this. Whenever this gets actually reviewed and merged, it will be squashed. Never force push with a squashed commit once a PR starts getting reviewed.

is there any nomenclature for git branching? can we name it better than wdongyu:fix_upsert_too_long_id, maybe as bug-103399-wdongyu? @wdongyu

Branch names mean nothing. As long as the branch merger references the issue ID in the commit message, its fine.

@wdongyu

This comment was marked as outdated.

@benwtrent benwtrent self-assigned this Jan 2, 2024
@benwtrent
Copy link
Member

@wdongyu I committed a change log entry for this change.

@benwtrent
Copy link
Member

buildkite test this

@benwtrent benwtrent removed their assignment Jan 2, 2024
@benwtrent benwtrent added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. and removed :Search/Search Search-related issues that do not fall into other categories labels Jan 2, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team label Jan 2, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine elasticsearchmachine removed the Team:Search Meta label for search team label Jan 2, 2024
@wdongyu
Copy link
Contributor Author

wdongyu commented Jan 10, 2024

this pr lefts a task only, could you assign an assignee @benwtrent @bohemia420

@benwtrent
Copy link
Member

I am pinging the experts on this part of the code.

Pinging @elastic/es-distributed (Team:Distributed)

@kingherc kingherc self-assigned this Jan 17, 2024
@kingherc
Copy link
Contributor

Hi, thanks for the PR! It looks reasonable. Initially I wondered whether we should consider this a breaking change or a bugfix, but after some discussion with the team, we're already documenting the 512 limit so we can consider this as a bugfix. Will rebase the branch, pass another final CI and will merge it afterwards.

@kingherc
Copy link
Contributor

buildkite test this

Copy link
Contributor

@kingherc kingherc left a comment

Choose a reason for hiding this comment

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

Follows the logic of testIndexingRejectsLongIds. LGTM.

@kingherc kingherc merged commit 4346a40 into elastic:main Jan 17, 2024
16 checks passed
@benwtrent
Copy link
Member

🎉 🎉 🎉 @wdongyu 🎉 🎉 🎉 Thank you for the contribution!!!

@wdongyu
Copy link
Contributor Author

wdongyu commented Jan 17, 2024

Thank you all guys for the approval of the first pr from a beginner😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Distributed Meta label for distributed team v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add validation on _id field when upsert new doc
7 participants