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

Fix #1106. Hydrate blocks on sync. #1107

Merged
merged 3 commits into from
Aug 27, 2021
Merged

Fix #1106. Hydrate blocks on sync. #1107

merged 3 commits into from
Aug 27, 2021

Conversation

chenilim
Copy link
Contributor

@chenilim chenilim commented Aug 25, 2021

This calls HydrateBlock on synched blocks via the websocket. HydrateBlock calls the appropriate constructor, which ensures that all required properties are set. This fixes the general problem of client code dealing with blocks with incomplete or outdated schemas, such as after a server upgrade.

Previously, HydrateBlocks was called by the handler of wsClient, but was refactored out. Calling this at the wsClient layer will ensure that downstream code has complete objects.

This parallels the call to HydrateBlocks in OctoClient (for REST APIs).

@chenilim chenilim requested a review from a team as a code owner August 25, 2021 21:52
@chenilim chenilim requested review from wiggin77, sbishel and jespino and removed request for a team August 25, 2021 21:52
@wiggin77
Copy link
Contributor

wiggin77 commented Aug 25, 2021

@chenilim shouldn't this happen on the server so that non-webapp clients also get fully formed blocks?

@chenilim
Copy link
Contributor Author

@wiggin77, agree this could be refactored. The gray area here is that a missing property is technically valid JSON, it's just that parts of our webapp code assumes that all objects have non-undefined properties.

I'll defer to you guys on the relative priority, but I can see moving the hydrateBlocks logic to the server side. Ideally there would be a clean way to keep the server blocks schema in sync with the TS blocks code, maybe via some sort of code generator?

@wiggin77
Copy link
Contributor

wiggin77 commented Aug 25, 2021

The gray area here is that a missing property is technically valid JSON

I think that valid JSON may not be a valid block based on whatever constraints/schema are expected. Someone using the REST API may expect valid blocks. I agree we should discuss how best to keep this in sync between webapp and server. I'll add it to dev meeting agenda.

That said, I guess it doesn't hurt to merge this, provided we revisit.

https://community.mattermost.com/boards/workspace/b1ni7nprjpfwpb566k1gk8z9nw/886d2280-e88e-4065-8c85-1b62578f192e/f30dcb19-a0e8-45d2-8768-a9489f6e7fe8?c=4ca2c009-419e-44c8-8bbd-7f0fa7813408

Copy link
Collaborator

@sbishel sbishel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenilim chenilim merged commit c3f5993 into main Aug 27, 2021
@chenilim chenilim deleted the hydrate-sync branch August 27, 2021 01:33
chenilim added a commit that referenced this pull request Aug 27, 2021
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
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