Skip to content

feat: add header validation#6859

Merged
sid-bruno merged 4 commits intousebruno:mainfrom
pooja-bruno:feature/header-validation
Jan 27, 2026
Merged

feat: add header validation#6859
sid-bruno merged 4 commits intousebruno:mainfrom
pooja-bruno:feature/header-validation

Conversation

@pooja-bruno
Copy link
Collaborator

@pooja-bruno pooja-bruno commented Jan 20, 2026

Description

Added validation for HTTP headers to show an error icon when users enter invalid header names or values.

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.
image

Summary by CodeRabbit

  • New Features
    • Header validation added: names may not contain spaces or newlines; values may not contain newlines. Invalid entries show a realtime error icon with explanatory tooltip.
  • UX
    • Consolidated and standardized error indicator display within editable header tables for consistent alignment and behavior.
  • Tests
    • Added end-to-end tests covering header name/value validation and UI error indicators.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Caution

Review failed

The head commit changed during the review from 31c3ce1 to 63d7f98.

Walkthrough

Adds header-name/value validation and UI error indicators. New regex utilities and per-row validation callbacks are wired into EditableTable across collection, folder, and request header editors; tests and test helpers updated for interaction and persistence.

Changes

Cohort / File(s) Summary
Header Validation Utilities
packages/bruno-app/src/utils/common/regex.js
Exported headerNameRegex (/^[^\s\r\n]*$/) and headerValueRegex (/^[^\r\n]*$/) for header validation.
Header Validation Integration
packages/bruno-app/src/components/CollectionSettings/Headers/index.js, packages/bruno-app/src/components/FolderSettings/Headers/index.js, packages/bruno-app/src/components/RequestPane/RequestHeaders/index.js
Imported regexes; added getRowError callbacks that validate name (no spaces/newlines; rejects whitespace-only where applicable) and value (no newlines, value optional); passed getRowError into EditableTable. RequestHeaders adjusted column render signatures.
EditableTable Error UI
packages/bruno-app/src/components/EditableTable/index.js
Introduced errorIcon (alert icon + tooltip) and appended it to rendered cell output for consistent per-cell error display.
Tests & Test Helpers
tests/request/headers/header-validation.spec.ts, tests/utils/page/actions.ts
Added Playwright header validation tests (name/value error states, tooltips, clearing); openRequest gained optional persist flag (double-click path) and tab-selection sync improvements.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Headers as "Headers Component"
    participant EditableTable as "EditableTable"
    participant Regex as "headerNameRegex / headerValueRegex"
    participant UI as "Error Icon + Tooltip"

    User->>Headers: Type header name/value
    Headers->>EditableTable: Provide getRowError callback
    EditableTable->>Headers: Call getRowError(row)
    Headers->>Regex: Validate name/value
    Regex-->>Headers: Return match result
    alt invalid
        Headers-->>EditableTable: Return error message
        EditableTable->>UI: Render alert icon + tooltip
        UI-->>User: Show error indicator
    else valid
        Headers-->>EditableTable: Return null
        EditableTable->>UI: No error shown
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

✨ Headers now watch what you type,
No stray spaces or line-breaks in sight,
A tiny red bell gives a gentle hint,
Fix the field and the error is squint —
🎉 Valid headers, tidy and bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add header validation' accurately describes the main change—introducing validation for HTTP headers across multiple components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/request/headers/header-validation.spec.ts`:
- Around line 68-94: This test relies on a request created elsewhere; make it
self-contained by creating or opening the request within this test (or move
shared setup into a beforeEach). Specifically, before calling
selectRequestPaneTab(page, 'Headers') ensure you create/open the request (e.g.,
use the same helper used in other specs or add steps to click "New Request" and
set its name/body) so the header table exists; keep usage of
getTableCell(headerRow, 1), CodeMirror interactions, tooltip assertions and the
final save (page.keyboard.press('Control+s')) unchanged but only after the
request is created/opened.
🧹 Nitpick comments (3)
packages/bruno-app/src/components/EditableTable/index.js (1)

182-195: Make error tooltip keyboard-accessible.

Consider making the error icon focusable and adding an aria label so keyboard users can discover the tooltip text.

♿ Suggested tweak
-    const errorIcon = error && !isEmpty ? (
-      <span>
+    const errorIcon = error && !isEmpty ? (
+      <span
+        tabIndex={0}
+        role="img"
+        aria-label={error}
+      >
         <IconAlertCircle
           data-tooltip-id={`error-${row.uid}-${column.key}`}
           className="text-red-600 cursor-pointer ml-1"
           size={20}
         />
         <Tooltip
           className="tooltip-mod"
           id={`error-${row.uid}-${column.key}`}
           html={error}
         />
       </span>
     ) : null;

Please verify react-tooltip shows on focus for focusable anchors.

Also applies to: 198-209, 226-226

tests/request/headers/header-validation.spec.ts (1)

58-60: Use cross‑platform shortcuts for Playwright.

Meta+a and Control+s are OS‑specific; use ControlOrMeta to keep tests portable.

🔧 Suggested update
-      await page.keyboard.press('Meta+a');
+      await page.keyboard.press('ControlOrMeta+A');
...
-      await page.keyboard.press('Control+s');
+      await page.keyboard.press('ControlOrMeta+S');

Please verify ControlOrMeta syntax in the Playwright version used here.

Also applies to: 92-93

packages/bruno-app/src/components/CollectionSettings/Headers/index.js (1)

36-50: Consider extracting shared header validation helper.

The same getRowError logic appears in CollectionSettings, FolderSettings, and RequestHeaders. A small helper (e.g., getHeaderRowError in utils/common/regex) would reduce duplication and keep error messages in sync.

Also applies to: 121-121

sid-bruno
sid-bruno previously approved these changes Jan 27, 2026
Copy link
Collaborator

@sid-bruno sid-bruno left a comment

Choose a reason for hiding this comment

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

LGTM, waiting on tests

@sid-bruno sid-bruno merged commit 21673f4 into usebruno:main Jan 27, 2026
5 of 6 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.

2 participants