Skip to content

fix(lang): guard ntlm domain on domainKey, not passwordKey - #8707

Merged
vijayh-bruno merged 1 commit into
usebruno:mainfrom
sbalagan22:fix/8695-ntlm-domain-guard
Aug 26, 2026
Merged

vijayh-bruno merged 1 commit into
usebruno:mainfrom
sbalagan22:fix/8695-ntlm-domain-guard

Conversation

@sbalagan22

@sbalagan22 sbalagan22 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

BRU-3988

Summary

An auth:ntlm block with username/password but no domain line threw a TypeError and the .bru failed to parse. This guards the domain lookup on the correct key so it defaults to an empty string.

Root cause

In authNTLM (packages/bruno-lang/v2/src/bruToJson.js), the domain line reads domainKey.value but guards on passwordKey:

const password = passwordKey ? passwordKey.value : '';
const domain = passwordKey ? domainKey.value : '';

When a block has a password but no domain, passwordKey is truthy while domainKey is undefined, so domainKey.value throws TypeError: Cannot read properties of undefined (reading 'value'). A valid request .bru with NTLM auth and no explicit domain fails to parse.

Fix

Guard the domain on domainKey, matching the username and password lines directly above:

const domain = domainKey ? domainKey.value : '';

Test plan

Added an auth:ntlm describe block to packages/bruno-lang/v2/tests/bruToJson.spec.js: one case with a domain line and one without. The no-domain case throws on the base branch and passes with the fix.

npx jest v2/tests/bruToJson.spec.js
Tests:       34 passed, 34 total

npx jest   # full bruno-lang suite
Test Suites: 32 passed, 32 total
Tests:       450 passed, 450 total

Fixes #8695.

Screenshots

Before After
Screenshot 2026-08-27 at 1 49 34 PM Screenshot 2026-08-27 at 1 50 18 PM

Summary by CodeRabbit

  • Bug Fixes

    • Corrected NTLM authentication parsing so the domain is properly recognized when provided.
    • NTLM configurations without a domain now consistently default to an empty domain value.
  • Tests

    • Added coverage for NTLM authentication with and without an explicit domain.

authNTLM read domainKey.value while guarding on passwordKey, so an
auth:ntlm block with a password but no domain line threw a TypeError and
failed to parse. Guard on domainKey to default domain to an empty string,
matching the username and password lines.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

NTLM parsing now checks domainKey before reading the domain value. Tests cover parsing with an explicit domain and defaulting to an empty string when the domain line is absent.

Changes

NTLM domain parsing

Layer / File(s) Summary
Fix NTLM domain fallback and add coverage
packages/bruno-lang/v2/src/bruToJson.js, packages/bruno-lang/v2/tests/bruToJson.spec.js
The parser derives auth.ntlm.domain from domainKey, while tests cover explicit and omitted domain values.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

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

Poem

A domain key now guards the door,
No missing field can crash the floor.
With credentials parsed and tests in flight,
NTLM lands safely, clean and right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code change and new tests address issue #8695 by preventing missing-domain NTLM parsing failures and defaulting domain to an empty string.
Out of Scope Changes check ✅ Passed The PR only changes NTLM parsing logic and adds targeted tests, with no unrelated or out-of-scope modifications visible.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the NTLM domain guard correction implemented in the 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.

@sbalagan22
sbalagan22 marked this pull request as ready for review July 22, 2026 18:47
@sbalagan22
sbalagan22 requested a review from helloanoop as a code owner July 22, 2026 18:47
Copilot AI review requested due to automatic review settings July 22, 2026 18:47

Copilot AI 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.

Pull request overview

Fixes a parser crash in the Bruno v2 .bru → JSON conversion when parsing auth:ntlm blocks that omit the optional domain field, ensuring NTLM auth parsing safely defaults domain to an empty string.

Changes:

  • Corrected the guard used when reading the NTLM domain value to check domainKey (not passwordKey), preventing TypeError on missing domain.
  • Added unit tests covering auth:ntlm parsing both with and without an explicit domain line.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/bruno-lang/v2/src/bruToJson.js Fixes NTLM domain lookup to avoid dereferencing undefined when domain is omitted.
packages/bruno-lang/v2/tests/bruToJson.spec.js Adds regression tests for NTLM auth parsing with/without domain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vijayh-bruno
vijayh-bruno merged commit 7052123 into usebruno:main Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auth:ntlm parsing throws TypeError when the domain line is absent

5 participants