FuelLabs / fuels-ts

Fuel Network Typescript SDK
https://docs.fuel.network/docs/fuels-ts/
Apache License 2.0
44.1k stars 1.34k forks source link

Better error messages for predicate setData #1552

Open arboleya opened 10 months ago

arboleya commented 10 months ago

The current encoding error messages were weak on details and should be improved.

[!NOTE]

nedsalk commented 9 months ago

One approach to do this is would be to make each coder aware of the abi it's encoding/decoding so that they can throw an abi-specific message like: encode-error: invalid u8 for property "a.b.c.d: passed in value is 24242, max is 255" or, to be fancier:

encode-error: invalid u8 while encoding abi:
{
  a: {
  a1: 54,
    b: {
      b1: "text",
      b2: "0xasdfwer",
      c: {
       c1: [1,2,3],
-----> d: Encoding 6464, max for u8 is 255.
      }
    }
  }
}

It would definitely be nice to have one of the above, but is it worthwhile to implement? On first hunch it feels like it would require a lot of custom code.

I don't see another way to substantially improve the error messages besides this.

@FuelLabs/sdk-ts What do you think?

nedsalk commented 9 months ago

@arboleya It might be wise to block this until the new encoding scheme is finished.

arboleya commented 8 months ago

Blocked by:

arboleya commented 7 months ago

@nedsalk @Dhaiwat10 Do you guys think this is still blocked, now that we merged https://github.com/FuelLabs/fuels-ts/pull/1826?

cc @petertonysmith94

petertonysmith94 commented 7 months ago

@arboleya I believe it's blocked by the new encoding #1672, rather than #1826.

In light of #1826, the problem will be on Predicate instantiation - rather than the setData method (which has been removed).

Maybe @Dhaiwat10 could confirm my understanding 🙏🏼

arboleya commented 7 months ago

I wonder if these errors weren't revert errors, in which case could be related to https://github.com/FuelLabs/fuels-ts/pull/1840.

petertonysmith94 commented 7 months ago

I believe this issue is in reference to the Coder based errors in general. They're super generic (in description) and I don't believe there is any feedback to where or how these errors have been thrown (I could be wrong).

Take for instance the ArrayCoder, wouldn't the index of the Array be useful.

Also the aggregate coders, take TransactionScriptCoder for instance, would be good to know the argument that failed - rather than Invalid u8. when an error occurs for the witnessCount.

arboleya commented 7 months ago

This feedback came in response to the development of the WebAuthn, referenced in the issue description:

petertonysmith94 commented 2 months ago

Changing topic from Library to ABI as it appears more related to encoding.

Better error messages for predicate setData | The current encoding error messages were weak on details and should be improved.