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

Handles the status code for . properties #4246

Merged
merged 3 commits into from
Aug 18, 2022

Conversation

owaiskazi19
Copy link
Member

@owaiskazi19 owaiskazi19 commented Aug 17, 2022

Description

This change returns a 400 status code when a mapping with "." properties is created
Previously

{
  "error": {
    "root_cause": [
      {
        "type": "array_index_out_of_bounds_exception",
        "reason": "Index -1 out of bounds for length 0"
      }
    ],
    "type": "array_index_out_of_bounds_exception",
    "reason": "Index -1 out of bounds for length 0"
  },
  "status": 500
}

Now:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "Index -1 out of bounds for length 0"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Index -1 out of bounds for length 0"
  },
  "status" : 400
}

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@owaiskazi19 owaiskazi19 requested review from a team and reta as code owners August 17, 2022 19:52
@owaiskazi19 owaiskazi19 requested a review from kartg August 17, 2022 19:53
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@peterzhuamazon peterzhuamazon changed the title Handles the status code for "." properties Handles the status code for . properties Aug 17, 2022
@peterzhuamazon
Copy link
Member

peterzhuamazon commented Aug 17, 2022

The failure is due to @owaiskazi19 use double quote " in the title thus cause the json parsing to be messed up.

Changed to .

image

@saratvemulapalli
Copy link
Member

The failure is due to @owaiskazi19 use double quote " in the title thus cause the json parsing to be messed up.

Changed to .

image

Sounds scary that a PR code expose internals of jenkins. :/

@owaiskazi19
Copy link
Member Author

The failure is due to @owaiskazi19 use double quote " in the title thus cause the json parsing to be messed up.

Changed to .

image

Thanks @peterzhuamazon . Shouldn't we handle such case before json parsing?

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

Signed-off-by: Owais Kazi <[email protected]>
@owaiskazi19 owaiskazi19 requested a review from kartg August 17, 2022 23:22
@kartg kartg added backport 1.x backport 2.x Backport to 2.x branch backport 1.3 Backport to 1.3 branch backport 2.2 Backport to 2.2 branch labels Aug 17, 2022
@kartg kartg added bug Something isn't working security Anything security related labels Aug 17, 2022
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2022

Codecov Report

Merging #4246 (c7b8630) into main (237f1a5) will decrease coverage by 0.12%.
The diff coverage is 78.04%.

@@             Coverage Diff              @@
##               main    #4246      +/-   ##
============================================
- Coverage     70.65%   70.53%   -0.13%     
+ Complexity    57075    57054      -21     
============================================
  Files          4606     4606              
  Lines        274706   274739      +33     
  Branches      40228    40232       +4     
============================================
- Hits         194103   193787     -316     
- Misses        64280    64604     +324     
- Partials      16323    16348      +25     
Impacted Files Coverage Δ
...c/main/java/org/opensearch/index/IndexService.java 74.09% <0.00%> (ø)
...nsearch/index/shard/CheckpointRefreshListener.java 88.88% <0.00%> (-11.12%) ⬇️
...in/java/org/opensearch/index/shard/IndexShard.java 70.10% <73.33%> (+0.45%) ⬆️
...rc/main/java/org/opensearch/index/store/Store.java 80.72% <81.25%> (-1.18%) ⬇️
.../opensearch/index/engine/NRTReplicationEngine.java 76.92% <100.00%> (+1.52%) ⬆️
...java/org/opensearch/index/mapper/ObjectMapper.java 92.44% <100.00%> (+0.77%) ⬆️
...ation/OpenSearchIndexLevelReplicationTestCase.java 90.27% <100.00%> (+0.47%) ⬆️
...gations/bucket/composite/CompositeAggregation.java 15.00% <0.00%> (-85.00%) ⬇️
...adonly/AddIndexBlockClusterStateUpdateRequest.java 0.00% <0.00%> (-75.00%) ⬇️
.../java/org/opensearch/node/NodeClosedException.java 50.00% <0.00%> (-50.00%) ⬇️
... and 482 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@owaiskazi19 owaiskazi19 merged commit 36f1d77 into opensearch-project:main Aug 18, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 18, 2022
* Return 400 status code for array out of bound

Signed-off-by: Owais Kazi <[email protected]>

* Spotless apply

Signed-off-by: Owais Kazi <[email protected]>

* PR comments

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 36f1d77)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 18, 2022
* Return 400 status code for array out of bound

Signed-off-by: Owais Kazi <[email protected]>

* Spotless apply

Signed-off-by: Owais Kazi <[email protected]>

* PR comments

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 36f1d77)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 18, 2022
* Return 400 status code for array out of bound

Signed-off-by: Owais Kazi <[email protected]>

* Spotless apply

Signed-off-by: Owais Kazi <[email protected]>

* PR comments

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 36f1d77)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 18, 2022
* Return 400 status code for array out of bound

Signed-off-by: Owais Kazi <[email protected]>

* Spotless apply

Signed-off-by: Owais Kazi <[email protected]>

* PR comments

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 36f1d77)
@dblock
Copy link
Member

dblock commented Aug 18, 2022

We have backported this in many versions because it's a bug fix. But it does change the API. Where are we documenting this breaking change? And is it ok at all?

kartg pushed a commit that referenced this pull request Aug 18, 2022
* Return 400 status code for array out of bound

Signed-off-by: Owais Kazi <[email protected]>

* Spotless apply

Signed-off-by: Owais Kazi <[email protected]>

* PR comments

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
(cherry picked from commit 36f1d77)

Co-authored-by: Owais Kazi <[email protected]>
owaiskazi19 added a commit that referenced this pull request Aug 22, 2022
@kartg
Copy link
Member

kartg commented Aug 22, 2022

We have backported this in many versions because it's a bug fix. But it does change the API. Where are we documenting this breaking change? And is it ok at all?

@dblock On the point of "is it ok" - I think we as a community get to decide :) I tagged this for backport since it turns an implicit restriction (. is not a valid field name) into an explicit one, and the API call would continue to fail as before. But, as you pointed out, it is an API change since the error code changes. Considering this again, in the interest of adhering to semver, I think backporting may not, in fact, be the right thing to do.

kartg pushed a commit that referenced this pull request Aug 23, 2022
…4276)

This reverts commit fafdd28.

Signed-off-by: Owais Kazi <[email protected]>

Signed-off-by: Owais Kazi <[email protected]>
@owaiskazi19 owaiskazi19 added backport 2.x Backport to 2.x branch and removed backport 2.x Backport to 2.x branch labels Feb 17, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

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

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-4246-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 36f1d77ad7983d9a58bfd755423ce806941fd930
# Push it to GitHub
git push --set-upstream origin backport/backport-4246-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-4246-to-2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.x backport 1.3 Backport to 1.3 branch backport 2.x Backport to 2.x branch backport 2.2 Backport to 2.2 branch bug Something isn't working security Anything security related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants