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

refactor: AgentSettings Circular Structure and improve internals #4641

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

sw-joelmut
Copy link
Collaborator

#minor

Description

This PR replaces the skipProperties functionality with an internal _replacer function when the JSON.stringify function gets called in the calculateChangeHash.
The calculateChangeHash has been changed to use a new internal stringify function, that allows to detect and handle Circular Structures.
Additionally, the AgentSettings configuration has being added to the getRuntimeServices function, so internal functionalities can use them. Not only that, the SkillClient has being updated based on this configuration, that work for both Composer and non-Composer bots.

Specific Changes

  • The BotState class has being updated, removing all the skipProperties functionality.
  • The calculateChangeHash has being refactored to handle Circular Structures and generate a hash, instead of a plain JSON.stringify value, so it is easier to debug and identify.
  • Added the ConnectorClientOptions to the start and getRuntimeServices functions for Composer bots, so it can be customizable, and delegate to the internal CoreBot to use.
  • The BeginSkill has being updated, removing the skipProperties and introducing the new internal _replace function, for the stringify functionality to execute.
  • Added a new stringify function that encapsulates the native JSON.stringify function, with the addition to handle Circular Structures and expose the internal _replacer function to customize it.
  • Updated the internal botFrameworkClientFetchImpl function to use a single instance of axios and handle its configuration from ConnectorClientOptions.

Testing

The following images show how the ConnectorClientOptions can be provided from a Composer bot perspective, the new stringify functionality that detects and replaces circular references, and the generated hash string.
image
image
image

@sw-joelmut sw-joelmut requested a review from a team as a code owner April 3, 2024 18:17
@coveralls
Copy link

coveralls commented Apr 4, 2024

Pull Request Test Coverage Report for Build 8543859968

Details

  • 40 of 56 (71.43%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 84.427%

Changes Missing Coverage Covered Lines Changed/Added Lines %
libraries/botbuilder-stdlib/src/stringify.ts 24 25 96.0%
libraries/botframework-connector/src/auth/botFrameworkClientImpl.ts 2 17 11.76%
Totals Coverage Status
Change from base Build 8543007355: 0.3%
Covered Lines: 20419
Relevant Lines: 22894

💛 - Coveralls

@tracyboehrer tracyboehrer merged commit d97afc2 into main Apr 16, 2024
12 checks passed
@tracyboehrer tracyboehrer deleted the southworks/fix/circular-structure-expose-agent branch April 16, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants