Skip to content

Fix cache path and add null-safety to sequence data rendering#67

Merged
t0mdavid-m merged 1 commit into
developfrom
claude/fix-nonetype-error-E8dMM
May 19, 2026
Merged

Fix cache path and add null-safety to sequence data rendering#67
t0mdavid-m merged 1 commit into
developfrom
claude/fix-nonetype-error-E8dMM

Conversation

@t0mdavid-m
Copy link
Copy Markdown
Member

@t0mdavid-m t0mdavid-m commented May 19, 2026

Summary

This PR fixes the cache directory path structure and adds null-safety checks to the sequence data rendering logic in the update module. The changes ensure the application gracefully handles cases where sequence data is unavailable.

Key Changes

  • Cache path simplification: Changed cache path from 'flashdeconv/cache' to 'cache' in both src/render/update.py and content/FLASHDeconv/FLASHDeconvLayoutManager.py. This aligns the cache directory structure with the workspace organization.

  • Null-safety for sequence data: Refactored update_data() function to handle cases where get_sequence() returns None:

    • Calls get_sequence() once and stores the result to avoid redundant calls
    • Returns empty dictionaries for sequence_data and internal_fragment_data when sequence is unavailable
    • Maintains existing behavior when sequence data is present
  • Code cleanup: Fixed trailing whitespace and improved code formatting for consistency

Implementation Details

The sequence data rendering now follows a defensive programming pattern:

  1. Retrieve sequence once at the start of the conditional block
  2. Check if sequence is None before attempting to render
  3. Populate empty data structures when sequence is unavailable, preventing downstream errors
  4. Only render fragment data when the component is 'Internal Fragment Map'

This prevents potential TypeError exceptions when trying to access sequence[0] on a None value.

https://claude.ai/code/session_01J1rbXX85Rs3K7gENQPUYmB

Summary by CodeRabbit

  • Refactor
    • Updated cache storage directory structure
    • Optimized data processing for sequence view and internal fragment map components

Review Change Stack

The Sequence View / Internal Fragment Map components crashed with
`TypeError: 'NoneType' object is not subscriptable` whenever a user
submitted a proteoform sequence and opened the FLASHDeconv viewer.

FLASHDeconvSequenceInput writes the sequence to `workspace/cache`,
and FLASHDeconvViewer reads it from the same path (so the layout
gains `sequence_view`). But `src/render/update.py:get_sequence` and
`FLASHDeconvLayoutManager` were looking at `workspace/flashdeconv/cache`,
so they never found the cached sequence and returned `None`. The
caller then subscripted `None[0]` and crashed.

Point both readers at `workspace/cache` to match the writer, and add
a defensive `if sequence is None: data['sequence_data'] = {}` branch
in `update_data` (matching the existing pattern used in the flashtnt
branch of `filter_data`) so a missing cache renders empty instead of
crashing.
@t0mdavid-m t0mdavid-m merged commit 06775ca into develop May 19, 2026
3 of 4 checks passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0a0d2ac-6966-4c55-bf5b-88da40f41a3b

📥 Commits

Reviewing files that changed from the base of the PR and between 1e5eba5 and f107715.

📒 Files selected for processing (2)
  • content/FLASHDeconv/FLASHDeconvLayoutManager.py
  • src/render/update.py

📝 Walkthrough

Walkthrough

This PR consolidates FileManager cache directory paths from nested flashdeconv/cache to workspace-level cache across the layout manager and sequence retrieval logic. The sequence data population in update_data is concurrently refactored to call get_sequence once and conditionally populate outputs based on available data and component type.

Changes

Cache consolidation and sequence data refactoring

Layer / File(s) Summary
Consolidated cache directory paths
content/FLASHDeconv/FLASHDeconvLayoutManager.py, src/render/update.py
FileManager cache paths are unified from nested flashdeconv/cache to workspace-level cache in both layout manager initialization (line 40) and sequence retrieval (line 19 in get_sequence).
Sequence data population refactoring
src/render/update.py
update_data logic for "Sequence View" and "Internal Fragment Map" components is rewritten to call get_sequence once, handle None by returning empty dicts, and conditionally populate internal_fragment_data only for the "Internal Fragment Map" component.

🐰 Cache unified, code consolidated bright,
Sequence logic now streamlined right,
One call instead of scattered calls,
Nested paths give way to workspace halls!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-nonetype-error-E8dMM

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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