Fix REST API 500 error and schemathesis flaky test#941
Conversation
…ests when 503 is a valid response (e.g. untrained project)
There was a problem hiding this comment.
Pull request overview
Fixes two issues encountered while testing untrained projects through the REST API: a NameError-induced 500 response when suggest_corpus/filter raised an AnnifException (because the success path executed after the except block referenced the unbound suggestion_results), and a flaky schemathesis test that flagged the legitimate 503 response as a server error.
Changes:
- Move the
suggestion_results_to_list(...)return inside thetryblock in_suggest, so the error path no longer falls through to code using an undefined variable. - Exclude the
not_a_server_errorschemathesis check intest_openapi_fuzzyso 5xx responses documented in the schema (e.g., 503) don't fail the fuzz test.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| annif/rest.py | Returns the serialized result inside the try block, preventing a 500 when an AnnifException is caught. |
| tests/test_openapi.py | Disables schemathesis' not_a_server_error check so documented 5xx responses don't cause spurious failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #941 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 103 103
Lines 8239 8241 +2
=======================================
+ Hits 8209 8211 +2
Misses 30 30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
osma
left a comment
There was a problem hiding this comment.
LGTM (can't approve this myself)
While working on #926 I had problems with a failing schemathesis test under GitHub Actions CI. Investigating it revealed two problems:
This PR fixes the two errors above.