Skip to content

Bug report: Device code login crashes when autoOpenLinksInBrowser is enabled #7167

@eschoeller

Description

@eschoeller

Description

m365 login --authType deviceCode crashes with TypeError: Expected a 'target' when autoOpenLinksInBrowser is true, because MSAL's DeviceCodeResponse.verificationUri can be undefined at runtime. Similarly crashes with copyDeviceCodeToClipboard enabled when response.userCode is undefined.

Steps to reproduce

m365 cli config set --key autoOpenLinksInBrowser --value true
m365 login --authType deviceCode

Expected results

Device code login proceeds, optionally opening browser if URI is available.

Actual results

TypeError: Expected a `target`
    at open (node_modules/open/index.js:315:9)
    at Auth.processDeviceCodeCallback

Proposed solution

Guard browserUtil.open() and clipboardy.writeSync() calls with null checks on response.verificationUri and response.userCode.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions