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

Reintroduce lidvid not found case when testing that the latest detection script runs #259

Merged
merged 2 commits into from
Mar 7, 2023

Conversation

tloubrieu-jpl
Copy link
Member

🗒️ Summary

Very simple change

⚙️ Test Data and/or Report

The test is part of the standard integration tests found in repository 'registry'

♻️ Related Issues

Fixes #258

@@ -357,7 +357,7 @@ public void setResponse(RestHighLevelClient client, SearchRequest request) throw
long hitCount = hits.getTotalHits().value;
if (hitCount == 1L) {
this.formatters.get(this.format).setResponse(hits.getAt(0), this.fields);
} else {
} else if (hitCount > 1L) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless I'm missing something, the logic change here seems incorrect - the idea of that set of conditionals is "if the response yields a single result, as expected, throw an error, otherwise there is an incorrect number of responses (either zero, or multiple), in which case a descriptive error should be thrown".

If this change addresses a test failure, the test case should be adjusted instead imho.

Copy link
Member Author

@tloubrieu-jpl tloubrieu-jpl Mar 2, 2023

Choose a reason for hiding this comment

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

0 is not an error since it can happen that the lidvid is not found in the database, in which case we want to return 404 error and not 500 with the message on latest script. The change I made makes the not found lidvid (0 found) return 404 again (tested with integration tests)

I can not be positive though that my approach is the best regarding the overall architecture of the application, @al-niessner would help us on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tloubrieu-jpl what you're saying makes sense, but let me take a closer look to make sure that this isn't in a context where exactly-one hit is expected - I recall changing this conditional a couple of weeks back and it doesn't seem like a simple/understandable mistake for me to have messed up the logic so badly during that change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's the commit in question if you want to get in before I do

22a0970?diff=split

Copy link
Member Author

Choose a reason for hiding this comment

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

@alexdunnjpl it does not look like your commit introduced that error, since before, the else clause was already both referring to cases with 0 or >1 results. The change I am proposing it to exclude the case 0 result from the else.

I am not questioning the behavior since after my PR, we are getting the expected behavior, but there might be a better way, especially more readable way of doing that.

Copy link
Contributor

Choose a reason for hiding this comment

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

@al-niessner could you chime in on whether the original logic (see 22a0970 pre-diff version) is a mistake, or correct given some context @tloubrieu-jpl and I are missing?

service/src/main/resources/application.properties Outdated Show resolved Hide resolved
@tloubrieu-jpl
Copy link
Member Author

@al-niessner could you review this PR ?

@alexdunnjpl
Copy link
Contributor

Branch test failure is due to bug fixed in ce237d3 which is already merged to main. Suggest cherry-picking that commit to confirm that BITs pass prior to merge.

@tloubrieu-jpl
Copy link
Member Author

@alexdunnjpl , since @al-niessner is mostly unavailable this week, I suggest to merge this PR (since it does what I expect).

@tloubrieu-jpl tloubrieu-jpl merged commit cefff1b into main Mar 7, 2023
@tloubrieu-jpl tloubrieu-jpl deleted the missing_404_258 branch March 7, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

not found lidvid does not return 404 error
2 participants