From 7ceb965f36c331cd88a910b11b39905410972f28 Mon Sep 17 00:00:00 2001 From: tracyboehrer Date: Tue, 2 Apr 2024 07:52:19 -0500 Subject: [PATCH] Tracyboehrer/get value parity (#4639) * DialogStateManager.getValue does not throw for missing Scope (DotNet parity) * Corrected DialogStateManager test --------- Co-authored-by: Tracy Boehrer --- libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts | 3 ++- .../botbuilder-dialogs/tests/memory/dialogStateManager.test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts b/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts index 1b525867e4..6edd703d50 100644 --- a/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts +++ b/libraries/botbuilder-dialogs/src/memory/dialogStateManager.ts @@ -118,7 +118,8 @@ export class DialogStateManager { // Get memory scope to search over const scope = this.getMemoryScope(segments[0].toString()); if (scope == undefined) { - throw new Error(`DialogStateManager.getValue: a scope of '${segments[0]}' wasn't found.`); + console.warn(`DialogStateManager.getValue: a scope of '${segments[0]}' wasn't found for '${pathExpression}'.`); + return returnDefault(); } // Search over path diff --git a/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js b/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js index c6b5461d10..4027b21f0e 100644 --- a/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js +++ b/libraries/botbuilder-dialogs/tests/memory/dialogStateManager.test.js @@ -229,7 +229,7 @@ describe('Dialog State Manager', function () { }); it('raise an error if getValue() called with an invalid scope.', function () { - assert.throws(() => this.dc.state.getValue('foo.bar')); + assert.strictEqual(this.dc.state.getValue('foo.bar'), undefined); }); it('raise an error if setValue() called with missing path.', function () {