Skip to content

fix: render Validate binary path modal as HTML instead of raw markup - #10394

Merged
asheshv merged 3 commits into
pgadmin-org:masterfrom
kundansable:fix-binary-path-html-rendering
Sep 7, 2026
Merged

fix: render Validate binary path modal as HTML instead of raw markup#10394
asheshv merged 3 commits into
pgadmin-org:masterfrom
kundansable:fix-binary-path-html-rendering

Conversation

@kundansable

@kundansable kundansable commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #10393.

  • Preferences → Paths → Binary Paths → Validate binary path was showing literal <b>...</b>/<br/> tags instead of formatted text. The endpoint built a pre-rendered HTML string, and the frontend call site was switched to the escaping notifier.alertText() during the XSS hardening pass (9e370d3cb) — correct for untrusted binary output, but the backend never stopped speaking HTML.
  • misc.validate_binary_path now returns structured data ([{utility, version}]) instead of markup.
  • The frontend composes the modal content as real React elements (<b> label + SafeMessage for the untrusted version text) and calls notifier.alert(), so nothing is HTML-parsed and no plaintext escaping is needed.
  • Renamed binary_path.ui.js.jsx since it now contains JSX; widened AlertContent's text propType to node to match its existing behavior (it already accepted non-string nodes from other callers).

Test plan

  • pycodestyle on the changed Python file — clean
  • yarn run eslint on the changed JS/JSX files — clean
  • yarn run jest --testPathPatterns="binary_path.ui" — 3 passed, including a new case asserting bold labels/line breaks render and no literal <b>/<br/> ever appears in the DOM
  • yarn run jest --testPathPatterns="ModalProvider" — 4 passed (propType widening doesn't regress existing behavior)
  • Manual: Preferences → Paths → Binary Paths → enter an invalid path → Validate binary path → confirm formatted, line-broken output (no raw tags)

Summary by CodeRabbit

  • Bug Fixes

    • Binary path validation results now display clear, per-utility version information.
    • Utilities without detected versions now show an appropriate fallback message.
    • Validation alerts render formatted labels and line breaks correctly instead of displaying raw markup.
  • UI Improvements

    • Binary path validation feedback is presented in a clearer alert dialog.
    • Alert content now supports richer formatted messages for improved readability.

The endpoint returned a pre-built <b>/<br/> HTML string, and the frontend
switched to the escaping alertText() during the XSS hardening pass
(9e370d3), so the modal showed literal tags instead of formatted text.
Return structured {utility, version} data from the backend and compose
the modal content as React elements on the frontend, keeping the
untrusted binary version output routed through SafeMessage.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: d99c0b17-a37b-4bc8-9dfb-7e88118add64

📥 Commits

Reviewing files that changed from the base of the PR and between fff57cf and 0e9ab76.

📒 Files selected for processing (1)
  • web/pgadmin/preferences/static/js/components/binary_path.ui.jsx

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


Walkthrough

The binary path validation endpoint now returns structured utility/version data. The UI converts this data into JSX alert rows, including a fallback for missing versions. Alert content accepts React nodes, and tests verify bold labels and line breaks render as elements.

Changes

Binary path validation

Layer / File(s) Summary
Structured validation response
web/pgadmin/misc/__init__.py
validate_binary_path returns utility and version dictionaries. Invalid-path handling remains unchanged.
Alert rendering and validation
web/pgadmin/preferences/static/js/components/binary_path.ui.jsx, web/pgadmin/static/js/helpers/ModalProvider.jsx, web/regression/javascript/schema_ui_files/binary_path.ui.spec.js
The UI renders structured results as JSX alert rows. AlertContent accepts React nodes. Tests verify missing versions, bold labels, and line breaks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to efc87

Binary-path validation now renders utility names and version output safely as formatted dialog content, including a not-found message for empty results. The change is ready to merge.

Sequence Diagram(s)

sequenceDiagram
  participant ValidationUI
  participant validate_binary_path
  participant BrowserNotifier
  ValidationUI->>validate_binary_path: Submit binary path
  validate_binary_path-->>ValidationUI: Return utility/version data
  ValidationUI->>BrowserNotifier: Display JSX alert rows
  BrowserNotifier-->>ValidationUI: Render alert content
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary fix: rendering the Validate binary path modal content instead of displaying raw HTML markup.
Linked Issues check ✅ Passed The changes satisfy issue [#10393]. The backend returns structured utility and version data, while the frontend renders bold utility names, line breaks, and safe version output. Empty or missing versi…
Out of Scope Changes check ✅ Passed All changes support the linked issue. The AlertContent prop type update and the added UI tests directly support rendering React content and validating the modal behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@hiteshjambhale

Copy link
Copy Markdown
Contributor

Backend (misc/init.py) — Clean change. Returning structured [{utility, version}] instead of an HTML string is the right API design. Removing gettext() around the whole blob was also a latent bug fix.
Frontend (binary_path.ui.jsx) — SafeMessage on the version string is correct since it comes from an external binary. One nit: use || instead of ?? — if a binary ever returns empty string stdout, ?? won't fall back to "not found" but || will.
ModalProvider.jsx — PropTypes.string → PropTypes.node widening is correct and matches how AlertContent already works internally. Non-string nodes bypass DOMPurify, so callers own sanitization — which this PR handles correctly.
Tests — Solid. The key assertion (no literal /
in DOM) is exactly the right regression guard. The await Promise.resolve() double-flush is fragile; waitFor would be safer, but it works for now.

@kundansable

|| instead of ?? — an empty-string version from an unexpected
'--version' output shape should still show the fallback message.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kundansable kundansable added this to the 9.18 milestone Sep 7, 2026

@hiteshjambhale hiteshjambhale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested manually — validated with /opt/homebrew/bin, versions render correctly with bold labels and line breaks. No raw /
tags.
LGTM ✅

@asheshv
asheshv merged commit 7c21772 into pgadmin-org:master Sep 7, 2026
19 of 34 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.

Validate binary path dialog displays raw HTML tags instead of rendered content

3 participants