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

Derek furst/hubma id in instanceof #628

Merged
merged 3 commits into from
Mar 5, 2024

Conversation

DerekFurstPitt
Copy link
Contributor

converted hubmapid to uuid before running schema_manager.entity_instanceof()

@@ -471,7 +471,8 @@ def get_ancestor_organs(id):
@app.route('/entities/<id>/instanceof/<type>', methods=['GET'])
def get_entities_instanceof(id, type):
try:
instanceof: bool = schema_manager.entity_instanceof(id, type)
uuid = schema_manager.get_hubmap_ids(id.strip())['uuid']
instanceof: bool = schema_manager.entity_instanceof(uuid, type)
except:
Copy link
Member

@yuanzhou yuanzhou Mar 1, 2024

Choose a reason for hiding this comment

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

@DerekFurstPitt the issue with your change by using get_hubmap_ids(id.strip())['uuid'] is when the target id is not found by uuid-api (404 error) or uuid-api considers the id format invalid (400 error), the client will always get "Unable to process request" 400 error due to the try/except handling.

Let's handle such exceptions particularly (still keep the generic except as what we have now as the last resort) to create a better user experience with more precise error messages. You can reuse the code from

entity-api/src/app.py

Lines 4809 to 4819 in 5194924

except requests.exceptions.RequestException as e:
# Due to the use of response.raise_for_status() in schema_manager.get_hubmap_ids()
# we can access the status codes from the exception
status_code = e.response.status_code
if status_code == 400:
bad_request_error(e.response.text)
if status_code == 404:
not_found_error(e.response.text)
else:
internal_server_error(e.response.text)

@yuanzhou yuanzhou merged commit b99b6d6 into dev-integrate Mar 5, 2024
2 checks passed
@yuanzhou yuanzhou deleted the Derek-Furst/hubma_id_in_instanceof branch March 7, 2024 14:23
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.

2 participants