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

cat search raises a KeyError in finesse-backend #49

Open
4 tasks
k-allagbe opened this issue Mar 13, 2024 · 0 comments
Open
4 tasks

cat search raises a KeyError in finesse-backend #49

k-allagbe opened this issue Mar 13, 2024 · 0 comments

Comments

@k-allagbe
Copy link
Member

Title:

Azure Index Search Endpoint Error Handling

Description:

➜  ~ curl -X POST http://localhost:5001/search/azure \
-H "Content-Type: application/json" \
-d '{"query": "cat"}'

{
  "details": "",
  "error": "Azure index search failed.",
  "trace": "Traceback (most recent call last):\n  File \"/home/vscode/.local/lib/python3.11/site-packages/index_search/__init__.py\", line 33, in transform\n    value = dpath.get(source_dict, path)\n            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/vscode/.local/lib/python3.11/site-packages/dpath/__init__.py\", line 189, in get\n    raise KeyError(glob)\nKeyError: '/@search.highlights/content/0'\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/home/vscode/.local/lib/python3.11/site-packages/flask/app.py\", line 870, in full_dispatch_request\n    rv = self.dispatch_request()\n         ^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/vscode/.local/lib/python3.11/site-packages/flask/app.py\", line 855, in dispatch_request\n    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/workspaces/finesse-backend/app/blueprints/search.py\", line 68, in search_azure\n    results = search(query, client, search_params, transform_map)\n              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/vscode/.local/lib/python3.11/site-packages/index_search/__init__.py\", line 54, in search\n    transformed_results = [\n                          ^\n  File \"/home/vscode/.local/lib/python3.11/site-packages/index_search/__init__.py\", line 55, in <listcomp>\n    transform(result, result_transform_map) for result in search_results\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/vscode/.local/lib/python3.11/site-packages/index_search/__init__.py\", line 36, in transform\n    raise DataTransformError from e\nindex_search.DataTransformError\n"
}

Configuration: FINESSE_BACKEND_AZURE_SEARCH_TRANSFORM_MAP={"id": "/id", "title": "/title", "score": "/@search.score", "url": "/url", "content": "/@search.highlights/content/0", "last_updated": "/last_updated"}

Tasks:

  • Investigate the cause of the KeyError in dpath.get function calls.
  • Ensure that the search results contain the expected highlight structure.
  • Implement error handling for missing dictionary keys in the result transformation process.
  • Add tests to cover the case when expected highlight structures are missing.

Acceptance Criteria:

  • The cat search should not result in a KeyError.
  • The server should handle missing data gracefully.
  • Adequate tests should demonstrate that the endpoint can handle missing highlight structures without failing.
@k-allagbe k-allagbe moved this to Todo in Finesse Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant