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

Catering to malformed documents #123

Open
yehjxraymond opened this issue Sep 25, 2020 · 1 comment
Open

Catering to malformed documents #123

yehjxraymond opened this issue Sep 25, 2020 · 1 comment

Comments

@yehjxraymond
Copy link
Contributor

Problem:

There is a test now that checks that the tests are skipped if the input is {}.

The problem is that in the test function, when we perform a getData, and TS shows the return type as WrappedDocument<v2.OpenAttestationDocument> not WrappedDocument<v2.OpenAttestationDocument> | undefined so it will be senseless to check for the malformed object in each and every of the verifier.

Here's some solutions, feel free to add more:

  1. Perform the check at OA level in the getData function to ensure that the returned object is of the right shape or throw.
  2. Perform the check BEFORE any verifications run to throw immediately instead of waiting for all the verifier to skip.
  3. Remove the test. If the user fucks it up, it's none of our business.
@Nebulis
Copy link
Contributor

Nebulis commented Sep 25, 2020

The problem is that in the test function, when we perform a getData, and TS shows the return type as WrappedDocument<v2.OpenAttestationDocument> not WrappedDocument<v2.OpenAttestationDocument> | undefined so it will be senseless to check for the malformed object in each and every of the verifier.

To be more accurate the problem is the difference between the compile time and the runtime type.

I'm for 2. for at least giving a good error message to the user (for 1. I don't think it concerns a lot getData to check more than the presence of the data field, but we could also throw an error from getData if there is no data field)

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

No branches or pull requests

2 participants