Skip to content

Strip stray backslash-escaping in query preview-row markdown cells (1.22.33)#81

Merged
Robbie1977 merged 1 commit into
mainfrom
fix/preview-row-stray-backslash-escaping
Jul 16, 2026
Merged

Strip stray backslash-escaping in query preview-row markdown cells (1.22.33)#81
Robbie1977 merged 1 commit into
mainfrom
fix/preview-row-stray-backslash-escaping

Conversation

@Robbie1977

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #80. That PR stripped the stray backslash-before-quote artifact
(e.g. y5B\'2ay5B'2a) from a term's own labels via
term_info_queries.clean_label. But query preview rows are assembled in
vfb_queries.py from raw Neo4j labels (apoc.text.format("[%s](%s)", ...))
and never pass through that path, so an embedded neuron label containing an
apostrophe still leaked the backslash into the preview name / thumbnail
markdown cells.

Concretely, get_term_info('VFB_jrchk0e3') in 1.22.32 returns a clean top-level
label but its NBLAST "similar neurons" preview still contains:

[MBON01(y5B\'2a)_R (FlyEM-HB:612371421)](VFB_jrchk0e2)

Because these aren't clean in the vfbquery response, they don't self-heal from
the v3-cached layer the way the term's own labels do.

Fix

Add the same stray-quote stripping into encode_markdown_links — the shared
"prepare a markdown cell for display" pass already responsible for securing
URLs and bracket-encoding labels for exactly these columns. Every preview
name / thumbnail / label cell is now cleaned in one vectorised pass,
covering both the image-markdown and label-shape branches. Guarded on a cheap
literal-backslash str.contains check so it stays essentially free on the large
frames this function was tuned for.

Mirrors term_info_queries.clean_label (re.sub(r"\\(['\"])", r"\1", ...)) so
a term's own labels and its query-preview labels are cleaned identically.

Testing

New network-free unit tests in src/test/test_preview_stray_backslash.py
exercise encode_markdown_links directly on production-shaped (object-dtype)
frames: link cells, image cells, clean-cell no-op, and null preservation. All
pass; the existing test_label_stray_backslash_cleaned still passes.

Verified end-to-end against live data: on a freshly-computed (uncached)
production-shaped frame the patched encoder reduces stray backslash-quote
occurrences in the VFB_jrchk0e3 similar-neurons preview from 2 to 0.

Version bumped to 1.22.33.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RQZ8eMr398cK1bnzN2XTqK

PR #80 cleaned a term's own labels (term_info_queries.clean_label), but query
preview rows are assembled in vfb_queries.py from raw Neo4j labels via
apoc.text.format and never pass through that path. So an embedded neuron label
containing an apostrophe (e.g. the NBLAST 'similar neurons' preview showing
MBON01(y5B\'2a)_R) still carried the stray backslash into the name/thumbnail
markdown cells.

Add the same stray-quote stripping into encode_markdown_links -- the shared
'prepare a markdown cell for display' pass already responsible for securing
URLs and bracket-encoding labels for these columns -- so every preview
name/thumbnail/label cell is cleaned in one vectorised pass. Guarded on a cheap
literal-backslash check so it stays essentially free on large frames.

Bump version to 1.22.33. Adds network-free unit tests over encode_markdown_links.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RQZ8eMr398cK1bnzN2XTqK
@Robbie1977
Robbie1977 merged commit 883c1d9 into main Jul 16, 2026
1 of 4 checks passed
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.

1 participant