Skip to content

Inconsistent return types in CardActionContext.getSignInUrl() #3439

@stevengum

Description

@stevengum

Line 118 returns a Promise, but line 125 returns a string or undefined:

getSignInUrl:
cardAction.type === 'signin'
? () => {
const { value } = cardAction;
if (directLine.getSessionId) {
// TODO: [P3] We should change this one to async/await.
// This is the first place in this project to use async.
// Thus, we need to add @babel/plugin-transform-runtime and @babel/runtime.
return observableToPromise(directLine.getSessionId()).then(
sessionId => `${value}${encodeURIComponent(`&code_challenge=${sessionId}`)}`
);
}
console.warn('botframework-webchat: OAuth is not supported on this Direct Line adapter.');
return value;

This causes an exception in createDefaultCardActionMiddleware() where it expects getSignInUrl to return a Promise:

const popup = window.open();
getSignInUrl().then(url => {
popup.location.href = url;
});

This issue was discovered while trying to use OAuth + Streaming (specifically DL ASE), though directLine.getSessionId may be falsey, the return values should have the same type.


Possible fix:

One solution is to return Promise.resolve(value); instead of return value;

image

FYI @jiruss, @DDEfromOR, @ckkashyap, @anusharavindrar

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or an unintended behavior.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions