Skip to content

Conversation

@aacic
Copy link
Collaborator

@aacic aacic commented Apr 28, 2025

This PR fixes a bug that occurs when multiple slides are loaded into the TileServer and multiple annotation overlays are subsequently uploaded in sequence.

Steps to reproduce:

  1. Load Slide 1 into the TileServer.

  2. Load Slide 2 into the TileServer.

  3. Upload the annotation overlay (GeoJSON) for Slide 1 via the /tileserver/overlay endpoint.

  4. Upload the annotation overlay (GeoJSON) for Slide 2 via the /tileserver/overlay endpoint.

  5. Attempt to load the overlay for Slide 1 via the /tileserver/layer/overlay/default/zoomify/ endpoint.

Expected behavior:
The annotation overlay for Slide 1 is displayed.

Actual behavior:
The annotation overlay for Slide 2 is displayed instead.

@aacic aacic force-pushed the fix-consecutive-annotations-bug branch from 0233f93 to f240903 Compare April 28, 2025 16:10
@aacic aacic marked this pull request as ready for review April 28, 2025 16:15
@codecov
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.70%. Comparing base (7ba7394) to head (f240903).
⚠️ Report is 19 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #927   +/-   ##
========================================
  Coverage    99.70%   99.70%           
========================================
  Files           71       71           
  Lines         8847     8847           
  Branches      1154     1154           
========================================
  Hits          8821     8821           
  Misses          23       23           
  Partials         3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aacic aacic requested review from measty and shaneahmed April 29, 2025 20:46
@shaneahmed shaneahmed added this to the Release v1.7.0 milestone Apr 30, 2025
@shaneahmed shaneahmed added the bug Something isn't working label Apr 30, 2025
@shaneahmed shaneahmed changed the title Fix consecutive annotations load bug. 🐛 Fix Consecutive Annotations Load Bug Apr 30, 2025
@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot May 9, 2025 10:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a bug where annotation overlays for slides were mismatched by incorporating session-specific temporary database files.

  • Update temporary database file naming using session_id to ensure overlays correspond to the correct session.
  • Adjust commit logic to correctly identify session-specific temporary files.

np.array(model_mpp) / np.array(self.slide_mpps[session_id]),
)
tmp_path = Path(tempfile.gettempdir()) / "temp.db"
tmp_path = Path(tempfile.gettempdir()) / f"temp_{session_id}.db"
Copy link

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

Ensure that session_id is sanitized or validated before using it in the file name to prevent potential file path injection vulnerabilities.

Suggested change
tmp_path = Path(tempfile.gettempdir()) / f"temp_{session_id}.db"
sanitized_session_id = re.sub(r'[^a-zA-Z0-9_]', '_', session_id)
tmp_path = Path(tempfile.gettempdir()) / f"temp_{sanitized_session_id}.db"

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tiatoolbox code generates the session ID, so this is not a concern.

else:
# make a temporary db for the new annotations
tmp_path = Path(tempfile.gettempdir()) / "temp.db"
tmp_path = Path(tempfile.gettempdir()) / f"temp_{session_id}.db"
Copy link

Copilot AI May 9, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider refactoring the logic for creating session-specific temporary file names into a helper function to avoid code duplication and potential inconsistencies in future modifications.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tiatoolbox code generates the session ID, so this is not a concern.

Copy link
Collaborator

@measty measty left a comment

Choose a reason for hiding this comment

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

Thanks for adding this bugfix, the PR looks fine to me

@shaneahmed shaneahmed merged commit 7ac64f1 into TissueImageAnalytics:develop May 16, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants