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

Do not throw error if alterFunc does not change the original key #249

Merged
merged 4 commits into from
Nov 4, 2024

Conversation

khushijain21
Copy link
Contributor

What does this PR do?

We do not throw error if alterFunc does not change the original key. This also improves error message for when key is not found

Why is it important?

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

@khushijain21 khushijain21 added the bug Something isn't working label Nov 2, 2024
@khushijain21 khushijain21 requested a review from a team as a code owner November 2, 2024 11:32
@khushijain21 khushijain21 requested review from mauri870 and VihasMakwana and removed request for a team November 2, 2024 11:32
@khushijain21 khushijain21 added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Nov 2, 2024
@khushijain21 khushijain21 requested a review from rdner November 2, 2024 11:33
Copy link
Member

@rdner rdner left a comment

Choose a reason for hiding this comment

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

Good catch, thanks!
A couple of minor comments.

mapstr/mapstr_test.go Outdated Show resolved Hide resolved
mapstr/mapstr.go Outdated
return fmt.Errorf("replacement key %q already exists: %w", newKey, ErrKeyCollision)

// if altered key is equal to the original key, skip below delete/put func
if newKey != key {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be more readable if it was just:

if newKey == key {
  return nil
}

Co-authored-by: Denis <denis@rdner.de>
Copy link
Member

@rdner rdner left a comment

Choose a reason for hiding this comment

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

LGTM, just an enhancement comment.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @khushijain21

@khushijain21 khushijain21 merged commit 7a31e0f into elastic:main Nov 4, 2024
6 checks passed
@khushijain21 khushijain21 deleted the alterpathbug branch November 4, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants