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

IDL Hashing does not follow upgrade spec #559

Open
krpeacock opened this issue Apr 11, 2022 · 4 comments
Open

IDL Hashing does not follow upgrade spec #559

krpeacock opened this issue Apr 11, 2022 · 4 comments
Assignees

Comments

@krpeacock
Copy link
Contributor

Describe the bug
By adding a new field to an error variant, I get back an error Cannot find field hash _2102411630_ when using a version of the generated delcarations without the new variant.

To Reproduce

  1. Deploy canister with type
  public type CreateInvoiceErr = {
    message : ?Text;
    kind : {
      #BadSize;
      #InvalidToken;
      #InvalidAmount;
      #InvalidDestination;
      #InvalidDetails;
      #MaxInvoicesReached;
      #Other;
    };
  };
  1. Generate declarations
  2. Add type #NotAuthorized;
  3. Redeploy, and make call using prior declarations

Expected behavior
Agent JS should make the call without the most up to date interface

@krpeacock
Copy link
Contributor Author

@chenyan-dfinity would you agree that this behavior is incorrect as-is?

@chenyan-dfinity
Copy link
Contributor

With the current implementation, I think we won't get the error unless you are sending the new tag #NotAuthorized as the value.

With the new spec change, the error variant should also be inside an opt value, so that when the client sees an unknown tag, we change it to null. See dfinity/candid#295. This has not been implemented in JS yet.

@krpeacock
Copy link
Contributor Author

I'm getting the error when receiving the new tag from the canister. Could we switch to a console.warn approach, while allowing the application logic to decide how to handle the unexpected tag?

@chenyan-dfinity
Copy link
Contributor

That's the goal. The error type should be opt CreateInvoiceErr, then null indicates the unknown tag.

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