Skip to content

[FIX] Handle unknown imageing modalities gracefully#644

Merged
rmanaem merged 3 commits into
mainfrom
bug-642
Oct 16, 2025
Merged

[FIX] Handle unknown imageing modalities gracefully#644
rmanaem merged 3 commits into
mainfrom
bug-642

Conversation

@rmanaem
Copy link
Copy Markdown
Contributor

@rmanaem rmanaem commented Oct 16, 2025

Checklist

This section is for the PR reviewer

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see our Contributing Guidelines for more info)
  • PR has a label for the release changelog or skip-release (to be applied by maintainers only)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass
  • If the PR changes the participant-level and/or the dataset-level result file, the query-tool-results files in the neurobagel_examples repo have been regenerated

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

Summary by Sourcery

Filter out unsupported imaging modalities in result cards and add tests to ensure unknown modalities are handled without breaking the UI

Bug Fixes:

  • Exclude unknown modalities from rendering in ResultCard to prevent undefined lookup errors

Tests:

  • Add Cypress fixtures and a component test to verify only recognized modalities are displayed when unknown modalities are present

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 16, 2025

Deploy Preview for neurobagel-query ready!

Name Link
🔨 Latest commit 80f37be
🔍 Latest deploy log https://app.netlify.com/projects/neurobagel-query/deploys/68f13e1b7870bd0008a5a48c
😎 Deploy Preview https://deploy-preview-644--neurobagel-query.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Oct 16, 2025

Reviewer's Guide

This PR enhances the ResultCard component to skip any imaging modalities not defined in the modalities map, and adds corresponding Cypress fixtures and a component test to verify that unknown modalities are silently ignored.

Class diagram for updated ResultCard modality handling

classDiagram
class ResultCard {
  +imageModals: string[]
  +modalities: object
}
ResultCard : +render()
ResultCard : +ButtonGroup
ResultCard : +filters imageModals to only those present in modalities
ResultCard --> ButtonGroup
ButtonGroup --> Button
Loading

File-Level Changes

Change Details Files
Filter out undefined modalities before rendering buttons
  • Added .filter(modal => modalities[modal]) to imageModals chain
  • Retained existing styling and key logic only for known modalities
src/components/ResultCard.tsx
Introduce fixtures for datasets containing unknown modalities
  • Defined datasetWithUnknownModality including one known and one unknown image_modals entry
  • Created responseWithUnknownModality wrapping the dataset fixture
cypress/fixtures/mocked-responses.ts
Add component test to ensure unknown modalities are excluded
  • Mounted ResultContainer with responseWithUnknownModality fixture
  • Asserted only the known modality button renders and count matches expected
cypress/component/ResultContainer.cy.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#642 Prevent the app from breaking when unknown imaging modalities are returned from the f-API.
#642 Handle unknown imaging modalities gracefully by either hiding them or showing them with default attributes.
#642 Add a test to verify that unknown imaging modalities do not break the app and are handled as specified.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@surchs surchs self-requested a review October 16, 2025 18:37
Comment thread cypress/component/ResultContainer.cy.tsx Outdated
Comment thread src/components/ResultCard.tsx Outdated
@rmanaem rmanaem added pr-bug-fix Bug fix, will increment patch version when merged (0.0.+1) release Create a release when this PR is merged labels Oct 16, 2025
@rmanaem rmanaem requested a review from surchs October 16, 2025 18:49
Copy link
Copy Markdown
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

Thanks @rmanaem, looks great

🧑‍🍳

@rmanaem rmanaem merged commit 3045551 into main Oct 16, 2025
15 of 16 checks passed
@rmanaem rmanaem deleted the bug-642 branch October 16, 2025 18:56
@neurobagel-bot
Copy link
Copy Markdown
Contributor

🚀 PR was released in v0.12.0 🚀

@neurobagel-bot neurobagel-bot Bot added the released This issue/pull request has been released. label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bug-fix Bug fix, will increment patch version when merged (0.0.+1) release Create a release when this PR is merged released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Receiving unknown imaging modality from fAPI breaks app

2 participants