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

js-sdk voip architecture: Input validation & types #1433

Open
dbkr opened this issue Sep 12, 2023 · 0 comments
Open

js-sdk voip architecture: Input validation & types #1433

dbkr opened this issue Sep 12, 2023 · 0 comments
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks

Comments

@dbkr
Copy link
Member

dbkr commented Sep 12, 2023

Your use case

https://github.com/matrix-org/matrix-js-sdk/blob/fc2671d8538a3339ca5925ef42e3ba6102f7e8f2/src/matrixrtc/CallMembership.ts#L40 takes a typed data structure and does further validation on it that should be unnecessary because of the types. This is a bit weird and confusing, but is because we are casting the raw content from the event into a CallMembershipData and then having the constructor take a typed interface, so we are technically lying about the type of the data between those points.

Now that I think about this more, I suspect the neatest solution would be to have a separate validator function that takes unknown, validates it and returns CallMembershipData or throws, then you can construct the CallMembership with a validated CallMembershipData.

Either way, we should do something less confusing, but still actually do explicit validation which we have often neglected in the past.

Have you considered any alternatives?

No response

Additional context

No response

@dbkr dbkr added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
No open projects
Development

No branches or pull requests

1 participant