Perhaps tells us what you're doing to get this pro...
# pact-js
m
Perhaps tells us what you're doing to get this problem and we can help
h
jsut run provider test, but just want to confirm that can I use single provider state for multiple test?
for example, providerState: create user id and return
id
and consumer test getUser, updateUser, deleteUser like this?
using all same
id
for all of the tests?
or each test should have an unique provider state?
btw the Rust error happens after
comparing to expected response: HTTP Response ( status: 200, headers: Some({"Content-Type": ["application/json;"]}), body: Present(39 bytes) )
JSON -> JSON: Comparing '2' to '3' using Type -> Ok(())
compare_values: Comparing 'Number(2)' to 'Number(3)' at path '$.data.setLinkGatingRule.id' -> Ok(())
then
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', pact_matching/src/headers.rs:22:45
happening
m
Yes, you should definitely be able to do that!
👍 1
It sounds like a bug to me. Could you please raise an issue with: • The version of jest-pact / pact-js you’re using • The pact file that causes the issue (or a minimal reproducable example we can use) • The actual provider response causing the issue You should be able to run just the test that is failing, but setting the
PACT_DESCRIPTION
environment variable to the one that’s exploding to isolate the problem
h
I cannot really share live pact in public repo, I have compared with passed test, so below message were missing when I got Rust error
Copy code
INFO  pact_verifier] Running provider state change handler 'A new link will be created' for 'a deleteLink request'
DEBUG pact_verifier::provider_client] Sending HTTP Request ( method: POST, path: /, query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(70 bytes, application/json) ) to state change handler
so I assume, some how, provider state step got wrong?
m
Perhaps. It's going to be hard to provide advice without a repro
We don't need your work code, we just need an example that can reproduce the problem
See howtorepro
m
It looks like the failure is during parsing charset characters. So that might be a clue
(charset in the content type header I'm guessing)
If you could even just share the pact file bits that have the content-type expectations and what your provider responds that will help
h
yeap it looks like a bug, I have send request to provider directly(without pact setup) it is working as expected lol my problem is I have no idea how to share repro code ..
as I got big fat complicated monolith provider setup lol
m
Great!
h
I got rust backtrace log, do you think it will help you?
m
Probably
But simplest is to just create a tiny little express app that returns a canned JSON (or whatever it is) with the appropriate that produces the fault. That, and the minimal pact file with the single interaction (ideally just the bits of the interaction) that elicit the failure
👍 1
h
Copy code
thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', pact_matching/src/headers.rs:22:45
 stack backtrace:
    0: rust_begin_unwind
              at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
    1: core::panicking::panic_fmt
              at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
    2: core::panicking::panic_bounds_check
              at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
    3: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
    4: pact_matching::headers::match_parameter_header
    5: pact_matching::headers::match_header_value
    6: pact_matching::headers::match_headers
    7: pact_verifier::verify_response_from_provider::{{closure}}
    8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
    9: <futures_util::future::future::flatten::Flatten<Fut,<Fut as core::future::future::Future>::Output> as core::future::future::Future>::poll
   10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   11: <futures_util::stream::stream::then::Then<St,Fut,F> as futures_core::stream::Stream>::poll_next
   12: pact_verifier::verify_provider_async::{{closure}}::{{closure}}
   13: <tokio::task::task_local::TaskLocalFuture<T,F> as core::future::future::Future>::poll
   14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   16: std::thread::local::LocalKey<T>::with
   17: tokio::park::thread::CachedParkThread::block_on
   18: tokio::runtime::thread_pool::ThreadPool::block_on
   19: tokio::runtime::Runtime::block_on
   20: pact_ffi::verifier::handle::VerifierHandle::execute
   21: pact_ffi::error::panic::catch_panic
   22: pactffi_verifier_execute
   23: _ZN4Napi11AsyncWorker18OnAsyncWorkExecuteEP10napi_env__Pv
 [2022-08-02 03:56:39.291 +0000] DEBUG (236 on 3b0d5f3b16db): pact@10.0.0-beta.60: outgoing response: {"body":"{\"data\":{\"setLinkGatingRule\":{\"id\":1}}}","headers":{"x-powered-by":"PHP/7.4.20","server":"nginx","content-type":"application/json","transfer-encoding":"chunked","connection":"close","set-cookie":["PHPSESSID=a79ad1a03d57970dedfb0d9a392fd4b9; path=/; HttpOnly; SameSite=lax"],"cache-control":"max-age=0, must-revalidate, private","date":"Tue, 02 Aug 2022 03:56:38 GMT","x-cache-debug":"1","x-debug-token":"bbbc3d","x-debug-token-link":"<http://nginx/_profiler/bbbc3d>","x-robots-tag":"noindex","expires":"Tue, 02 Aug 2022 03:56:39 GMT"},"status":200}
   24: worker
              at /home/iojs/build/ws/out/../deps/uv/src/threadpool.c:122:5
   25: start_thread
   26: clone
 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
 [2022-08-02T03:56:39Z DEBUG pact::matching::ffi] pact_ffi::verifier::pactffi_verifier_shutdown
m
are you testing a PHP app from JS?
oh, are you pointing at a live server?
h
are you testing a PHP app from JS?
yes
m
😆
h
oh, are you pointing at a live server?
yes local docker compose build
yeap this is not a best practice but, we have some issue with old monolith… so I had to build everything lol with live DB too
👍 1