Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BotFramework-Config Service Models Accept Any Type #634

Closed
justinwilaby opened this issue Nov 14, 2018 · 1 comment
Closed

BotFramework-Config Service Models Accept Any Type #634

justinwilaby opened this issue Nov 14, 2018 · 1 comment
Assignees
Labels
4.3 February 14, 2019 Release

Comments

@justinwilaby
Copy link
Contributor

justinwilaby commented Nov 14, 2018

Given this example:

const blobService = new BlobStorageService():
Object.assign(blobService, {connectionString: 'some string', type: ServiceTypes.Dispatch}); // Should throw but doesn't since we are changing the type erroneously. 

assert(blobService instanceof BlobStorageService); // true

const surprise = BotConfigurationBase.serviceFromJSON(blobService);
assert(surprise instanceof BlobStorageService); // throws
assert(surprise instanceof DispatchService); // Oops! Changed the class type.
assert('connectionString' in surprise); // 'connectionString' is a property of BlobStorageService but somehow arrives in a DispatchService instance

The shape of service data models are not necessarily reliable and seemingly completely interchangeable which can lead to failures when using the instanceof operator or erroneously setting the wrong type on a "typed" data model instance.

One would expect the type field to be read-only and properties that do not belong to the data model to be omitted from the instance.

@sgellock sgellock added 4.3 February 14, 2019 Release Discussion labels Nov 14, 2018
@tomlm
Copy link
Contributor

tomlm commented Jan 31, 2019

This is by design.

The reason is that you have components that might not be in sync as to the objects which are stored in the .bot file. If you run a tool which is older you want to "round-trip" properties which aren't understood (because they are new), or types which aren't understood (because they are new).

@tomlm tomlm closed this as completed Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 February 14, 2019 Release
Projects
None yet
Development

No branches or pull requests

3 participants