Skip to content

fix(variable-tooltip): mask secret variables of non-string dataType - #8606

Merged
bijin-bruno merged 4 commits into
usebruno:mainfrom
pooja-bruno:fix/variable-tooltip-secret-non-string-mask
Jul 14, 2026
Merged

bijin-bruno merged 4 commits into
usebruno:mainfrom
pooja-bruno:fix/variable-tooltip-secret-non-string-mask

Conversation

@pooja-bruno

@pooja-bruno pooja-bruno commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes the variable-info tooltip rendering an empty value for secret variables whose dataType is not a string (number, boolean, object).

Root cause: getMaskedDisplay measured .length on the raw value to decide how many mask characters (*) to render. A non-string value (e.g. the number 12345) has no .length, so it evaluated to undefined, producing zero mask characters a blank tooltip. Plain (non-secret) variables were unaffected because they skip masking and coerce to a string via textContent.

JIRA

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Screen.Recording.2026-07-14.at.6.56.02.PM.mov

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved masked secret-variable rendering so null/undefined display correctly, and masking length is computed more reliably across typed values (number, boolean, object).
  • Tests

    • Refreshed end-to-end coverage for request URL variables and variable info popups using shared helpers and testid-based selectors.
    • Expanded typed secret scenarios (global and folder variables), including masking/non-leak checks, reveal behavior, pinned tooltip editing persistence, and copy-latest-value validation.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

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: Pro

Run ID: 26072783-377b-476b-986d-86d7ba456fc3

📥 Commits

Reviewing files that changed from the base of the PR and between ca8ecd4 and b9eabce.

📒 Files selected for processing (3)
  • tests/utils/page/actions.ts
  • tests/utils/page/locators.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/utils/page/actions.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts

Walkthrough

The PR adds stable test identifiers to request URL and variable tooltip elements, updates masking for non-string values, introduces typed-variable test utilities, and expands tooltip coverage for typed, object, and global secret variables.

Changes

Variable tooltip coverage

Layer / File(s) Summary
Tooltip DOM hooks and masking
packages/bruno-app/src/components/RequestPane/QueryUrl/index.js, packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
Adds test identifiers throughout the URL editor and variable information popup, and updates masked-value length handling for nullish and non-string values.
Typed-variable test utilities
tests/utils/constants/*, tests/utils/page/actions.ts, tests/utils/page/locators.ts
Adds typed secret cases, supports typed environment variables, introduces URL tooltip helpers, and replaces CSS selectors with test-id-based locators.
Tooltip scenario coverage
tests/variable-tooltip/variable-tooltip.spec.ts
Refactors tooltip tests around shared helpers and expands coverage for typed secrets, object values, editing, copying, and global secret variables.

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

Possibly related PRs

  • usebruno/bruno#6312: Both PRs modify variable-info tooltip rendering and related variable display paths.
  • usebruno/bruno#7907: Both PRs modify variable-info tooltip masking, display, and copy behavior.
  • usebruno/bruno#8362: Both PRs cover object-value serialization and copying in variable tooltips.

Suggested reviewers: bijin-bruno, helloanoop, lohit-bruno, naman-bruno, sid-bruno

Poem

Tokens glow where tooltips bloom,
Secrets hide, then reveal room.
Typed values march in line,
Shared locators make tests shine.
Global vars join the tune.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: masking secret variables with non-string data types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/utils/page/actions.ts (1)

818-829: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Helper functions embed expect(...); per the E2E guide, assertions belong in specs.

addRowToActiveTab (818-829) and openUrlVarTooltip (2439-2452) each contain expect(...) calls used purely for synchronization ("settle signal"). Per the referenced guide, page-module helpers should synchronize with waitFor/locator waits and leave pass/fail assertions to the calling specs.

openUrlVarTooltip has a clean one-line fix; addRowToActiveTab's attribute check can use locator.and() to narrow without asserting:

♻️ Suggested sync-only rewrites
   const tooltip = varInfoPopup.all().first();
-  await expect(tooltip).toBeVisible();
+  await tooltip.waitFor({ state: 'visible' });
   return tooltip;
-      await expect(dataTypeSelector.typeLabel(row)).toHaveAttribute('data-selected-type', dataType);
+      await dataTypeSelector.typeLabel(row)
+        .and(page.locator(`[data-selected-type="${dataType}"]`))
+        .waitFor();

Note: many pre-existing helpers in this file (createCollection, createRequest, closeAllCollections) already embed expect(...) too, so this isn't a new pattern in the codebase — flagging for awareness rather than as a blocker.

Based on path instructions for tests/**/**.*, which state (per docs/playwright-testing-guide.md): "helper/action functions should synchronize (wait for UI readiness) but must not contain expect(...); specs should own pass/fail intent."

Also applies to: 2439-2452

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/utils/page/actions.ts` around lines 818 - 829, Remove the
synchronization-only expect(...) calls from addRowToActiveTab and
openUrlVarTooltip. Replace them with locator-based waits, narrowing the
data-type locator with locator.and() where needed to wait for the selected
attribute without asserting; preserve the existing UI readiness behavior and
leave pass/fail assertions to calling specs.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/variable-tooltip/variable-tooltip.spec.ts`:
- Around line 79-81: Centralize the variable locators used by the spec instead
of filtering `.cm-variable-*` directly. Extend `request.bodyVariableToken` to
accept the same state parameter as `request.urlVariableToken`, add a
corresponding helper for the header/auth value editor, and update both affected
spots in the test to use these locator helpers.

---

Nitpick comments:
In `@tests/utils/page/actions.ts`:
- Around line 818-829: Remove the synchronization-only expect(...) calls from
addRowToActiveTab and openUrlVarTooltip. Replace them with locator-based waits,
narrowing the data-type locator with locator.and() where needed to wait for the
selected attribute without asserting; preserve the existing UI readiness
behavior and leave pass/fail assertions to calling specs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 571af7f9-5b05-419a-a9f8-fdb584732e69

📥 Commits

Reviewing files that changed from the base of the PR and between 4d63acb and d79e2bb.

📒 Files selected for processing (7)
  • packages/bruno-app/src/components/RequestPane/QueryUrl/index.js
  • packages/bruno-app/src/utils/codemirror/brunoVarInfo.js
  • tests/utils/constants/index.ts
  • tests/utils/constants/variables.ts
  • tests/utils/page/actions.ts
  • tests/utils/page/locators.ts
  • tests/variable-tooltip/variable-tooltip.spec.ts

@sachin-thakur-bruno sachin-thakur-bruno left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

tested locally. working as expected

@bijin-bruno
bijin-bruno merged commit 10f2fc0 into usebruno:main Jul 14, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants