Hi folks, started getting this on the provider sid...
# pact-js
a
Hi folks, started getting this on the provider side, any ideas? Nothing was changed on consumer or provider sides
Copy code
Pact::UnexpectedIndex
and
Copy code
* Actual array is too long and should not contain a Hash at $.identity_locations[1]
t
“Hash” is the pact Rust core’s way of saying that the array contained an object
(that’s probably a defect in the Rust core, as I don’t think people are used to talking about json objects as “json hashes”)
This message says that the actual array contained two items
but it was expected to contain one
Without more details, it’s hard to tell what has changed.
a
strange, because my expected is like so I only check types of id and name, and don’t check anything else
Copy code
.willRespondWith({
        status: 200,
        headers: {
          'Content-Type': 'application/json; charset=utf-8',
        },
        body: {
          identity_locations: eachLike({
            id: '123',
            name: 'xxx',
          }),
        },
      });
i can see the actual. It did not change.
t
What do you mean by it did not change?
a
the provider response did not change. It’s as expected with nothing extra
t
Did not change from what?
Perhaps open an issue - we’ll need the logs and the full test in order to understand what is happening
a
ahh missed you message that “but it was expected to contain one” but i have the eachLike, which handles arrays
t
The error message is saying that it wasn’t expected to contain two.
I suspect that the contract that is being verified isn’t from the code that you’re sharing.
Which is why we need the full log
a
sorry, cannot provide full log but it is from correct test and i have 5 similar failures 😕
t
I would run the verifier with debug logging on. I guess that the contract that you’re verifying isn’t from that test, but also I can only guess without more information.
The error message is saying that it wasn’t expected to contain two.
This is the key point. Either your provider is returning two when it is supposed to return one, or the expectation in the contract is expecting one, when it is supposed to be expecting one or more.
☝️ 1
Or, there’s a bug, although I think that’s unlikely as this matcher is used widely.
m
BTW I think that's a Ruby type so my guess is this an older version. The issue template will sort that out
t
oh right yeah. I think the rust core still calls them non-objects. Dictionary, maybe?
Map! Looks like I complained about this already: https://github.com/pact-foundation/pact-reference/issues/222
it should be object. That’s what the O in json is for.
👌 2