fix: resolve 500 errors on missing keywords and unsafe 404 handler, a…#179
Open
TesfamichaelA-code wants to merge 1 commit into
Open
fix: resolve 500 errors on missing keywords and unsafe 404 handler, a…#179TesfamichaelA-code wants to merge 1 commit into
TesfamichaelA-code wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…dd tests
Description
Found two bugs while reading through the backend for my GSoC application and fixed them:
If you hit /news_keywords without a ?keywords= value (or with an empty one), the code tried to access user_keywords[0] on an empty list and crashed with a 500. Now returns a 400 instead.
The 404 handler called g.news_controller.notFound() without checking if g.news_controller was actually set. On bad routes it never gets initialized, so you'd get a 500 error while trying to handle a 404. Added a hasattr() check to handle this gracefully.
The existing test_news and test_news_keywords tests were hitting /news and /news_keywords directly, which match the /<llm_name> catch-all route — not the actual news endpoints. Fixed those. Also added tests for the missing/empty param cases, and switched to /raw endpoints so the suite doesn't need a HuggingFace API key to run in CI.
Related Issue
No related issue — found these bugs while reading through the codebase for my GSoC 2026 application.
How Has This Been Tested?
Ran unitTest.py locally, all 5 tests pass. Also tested manually by hitting a bad URL and intentionally running without a .env file to confirm CI safety.
Types of changes
Checklist: