poison icon indicating copy to clipboard operation
poison copied to clipboard

Poison.decode/1 invalid method signature.

Open KamilLelonek opened this issue 7 years ago • 7 comments

According to the documentation:

decode(iodata, options \\ [])
decode(iodata, Keyword.t) ::
  {:ok, Poison.Parser.t} |
  {:error, :invalid} |
  {:error, {:invalid, String.t}}

The invalid cases are either {:error, :invalid} or {:error, {:invalid, String.t}}.

However, have a look at this example:

iex(1)> Poison.decode "{"
{:error, :invalid, 1}

so we are getting {:error, :invalid, integer()}.

And that one:

iex(18)> Poison.decode "}"
{:error, {:invalid, "}", 0}}

which is basically: {:error, {:invalid, String.t(), integer()}}

Aren't docs up to date then?

KamilLelonek avatar Nov 07 '17 07:11 KamilLelonek

I am seeing the same issue on 3.0.0 and 3.1.0. Looks like it is due to this commit: https://github.com/devinus/poison/commit/50f25b752608ad156dcba5ca6cc989e5523b73ae

This is acceptable because of the major version bump, and surely would have been mentioned in the CHANGELOG if there was one.

However, this change was then removed: https://github.com/devinus/poison/commit/a4208a6252f4e58fbcc8d9fd2f4f64c99e974cc8#diff-574cf330de0ee486ba021c9eaa1f0e7bL42 so it seems that 4.0.0 will have the original 2.X behavior.

@KamilLelonek -- Can you verify the version you were using when conducting the above test?

Perhaps @devinus can explain the reasoning for the change and subsequent revert?

keyan avatar Dec 04 '17 18:12 keyan

From what I see, I was using 3.1.0 version when this issue occurred.

KamilLelonek avatar Dec 05 '17 16:12 KamilLelonek

Bump.

alakra avatar Apr 24 '18 20:04 alakra

@alakra -- the conclusion above was that this issue appears to be limited to 3.0.0 and 3.0.1. Please include what version you are using and also try upgrading first.

keyan avatar Apr 26 '18 18:04 keyan

this issue appears to be limited to 3.0.0 and 3.0.1

Not really. I'm using 3.1.0.

KamilLelonek avatar Apr 26 '18 19:04 KamilLelonek

Yeah sorry, my mistake, the fix is only on master. And creating a new release would be a major version bump.

keyan avatar Apr 26 '18 19:04 keyan

So how is this going?

This kind of problem is the prime candidate to create a bugfix-release for 3.1.X that has updated documentation to match the actual behaviour that Poison has.

Qqwy avatar Oct 08 '18 10:10 Qqwy