-
Notifications
You must be signed in to change notification settings - Fork 70
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: better exception message #969
base: main
Are you sure you want to change the base?
Conversation
Previously used docId for saying where the problem is, there is no gauarantee that this field exists instead _id is always guaranteed to be there. Also logging of the mapping was provided because it may be misleading when a user has a number as a string. It can be confusing for a user to something like [3.3] is not a number when the reality is that it was sent like "3.3" thus the type of the value is provided to help users understand better Signed-off-by: Brian Flores <[email protected]>
Thanks for creating this PR. Can you provide a few examples so that I can better understand the nuance between |
@@ -985,7 +985,10 @@ public void testRerank_throwsExceptionOnHavingNonNumericValue_WhenTargetFieldHas | |||
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class); | |||
verify(listener, times(1)).onFailure(argumentCaptor.capture()); | |||
|
|||
assertEquals("The field mapping to rerank by [hello world] is not Numerical", argumentCaptor.getValue().getMessage()); | |||
assertEquals( | |||
"The field mapping to rerank by [hello world] is not Numerical, instead of type [java.lang.String]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you turn it into a string format, where [java.lang.String]
gets in the same way as typeOfMapping
?
} | ||
|
||
Optional<Object> val = getValueFromSource(sourceMap, targetField); | ||
|
||
if (!(val.get() instanceof Number)) { | ||
log.error(String.format(Locale.ROOT, "The field mapping to rerank [%s: %s] is not Numerical", targetField, val.orElse(null))); | ||
// Strictly get the type of value removing the prefix of getClass() having a value is guaranteed so no NPE check | ||
String typeOfMapping = val.get().getClass().toString().replace("class ", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that val.get().getClass().toString()
also have strings like class
? I would suggest replaceFirst
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getClass().getSimpleName()
should be enough to avoid the replace and give you just the class name
can you please check that this will work when the |
@brianf-aws is this still work in progress? |
Hey @martin-gaievski I paused on this mainly because we mentioned this was not urgent. I am not sure what time I should prioritize this, what are your thoughts? |
I don't think it's high priority, how about we close the PR for now, and then reopen once you have bandwidth for it? Let me know if you have objects/concerns |
Sounds good, thanks for understanding |
Hey everyone I want to reopen this PR and work on it, I should have more bandwidth with the holidays coming up. |
Good to see this reopened @brianf-aws, please let us know once it's ready for review |
@brianf-aws Is there any update? We can help you if you came across some challenges. |
Description
Fixes two logging issues
[3.3] is not numerical
This makes it very difficult to understand why It didn't rerank. In this commit it provides the class of the mapping used to rerank to let the user now why it went wrong._id
is.Instead this commit makes sure that it usesgetId()
instead ofdocID()
. Previously if you had indexed your document and then used docId it would return -1 when it had no direct document field.Testing
./gradlew spotlessApply
./gradlew integTest
./gradlew test
to check UTWhy this occurred?
Related Issues
Check List
--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.