Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

[BUG] Safeguard against undefined modalities #305

Closed
1 task done
rmanaem opened this issue Nov 28, 2023 · 3 comments · Fixed by #307
Closed
1 task done

[BUG] Safeguard against undefined modalities #305

rmanaem opened this issue Nov 28, 2023 · 3 comments · Fixed by #307
Assignees
Labels
type:bug Defects in shipped code and fixes for those defects

Comments

@rmanaem
Copy link
Collaborator

rmanaem commented Nov 28, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Expected Behavior

The app should behave the same in both environments.

Current Behavior

When running the app in dev mode on the main branch the app seems to break and respond with a rather ambiguous error once the Submit Query button is clicked. However, the app runs just fine when running in production and was built by running npm run generate and npm run start

Error message

Screenshot from 2023-11-28 17-34-01

image

Environment

No response

How to reproduce

npm run dev on the main branch, then run an empty query
vs
npm run generate and npm run start, then run an empty query

Anything else?

No response

@rmanaem rmanaem added the type:bug Defects in shipped code and fixes for those defects label Nov 28, 2023
@rmanaem rmanaem self-assigned this Nov 28, 2023
@rmanaem rmanaem moved this to Implement - Active in Neurobagel Nov 28, 2023
@surchs
Copy link
Contributor

surchs commented Nov 28, 2023

good catch @rmanaem. It would be good to understand the difference. But more importantly we should remove the local non-static build scripts and make sure that we develop, test, and then run all in the same way that we deploy. So in other words: the fix for this is not so much to make npm run dev succeed again, but rather to replace npm run dev in development with npm run generate && npm run start!

@surchs
Copy link
Contributor

surchs commented Nov 29, 2023

I did a little bit of digging, here is what I found:

  1. This is unrelated to development mode or production mode. It only appears as if it was because in production mode the app doesn't crash out. But if you look at the dev console, the errors are the same
  2. The error is coming from the fact that we blindly trust the API to not return null or undefined as an imaging modality and chain off of the modalities with no protection
  3. The API has unfortunately started returning null as an imaging modality: API returns null as image modality api#232

This breaks all statements of the form modalities[modality] in this section:
https://github.com/neurobagel/query-tool/blob/b8df22b97c7680e67c39ea6533baa73133c174fd/components/ResultCard.vue#L71-L74

because modalities[modality] will be undefined.

Although this will be fixed in the API, we will also have to protect here against a modality being null in the future, e.g. by using optional chaining, see "robustness principle".

@rmanaem
Copy link
Collaborator Author

rmanaem commented Nov 29, 2023

I'll rename this issue and work on a safeguard.

@rmanaem rmanaem changed the title [BUG] App behaves different in dev vs prod environments [BUG] Safeguard against undefined modalities Nov 29, 2023
@rmanaem rmanaem changed the title [BUG] Safeguard against undefined modalities [BUG] Safeguard against undefined modalities Nov 29, 2023
@rmanaem rmanaem moved this from Implement - Active to Implement - Done in Neurobagel Nov 29, 2023
@surchs surchs moved this from Implement - Done to Review - Active in Neurobagel Nov 29, 2023
@github-project-automation github-project-automation bot moved this from Review - Active to Review - Done in Neurobagel Nov 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Defects in shipped code and fixes for those defects
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants