Repository navigation
fix(lang): guard ntlm domain on domainKey, not passwordKey - #8707
Conversation
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.
WalkthroughNTLM parsing now checks ChangesNTLM domain parsing
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
domainvalue to checkdomainKey(notpasswordKey), preventingTypeErroron missing domain. - Added unit tests covering
auth:ntlmparsing both with and without an explicitdomainline.
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.
BRU-3988
Summary
An
auth:ntlmblock withusername/passwordbut nodomainline threw aTypeErrorand the.brufailed 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 readsdomainKey.valuebut guards onpasswordKey:When a block has a password but no domain,
passwordKeyis truthy whiledomainKeyisundefined, sodomainKey.valuethrowsTypeError: Cannot read properties of undefined (reading 'value'). A valid request.bruwith NTLM auth and no explicit domain fails to parse.Fix
Guard the domain on
domainKey, matching theusernameandpasswordlines directly above:Test plan
Added an
auth:ntlmdescribe block topackages/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.Fixes #8695.
Screenshots
Summary by CodeRabbit
Bug Fixes
Tests