Hi, another question about `Stub Server (Rust)` : ...
# pact-rust
t
Hi, another question about
Stub Server (Rust)
: If I run this command:
Copy code
PACT_BROKER_BASE_URL=abc ./vendor/pact-foundation/pact-php/bin/pact-stub-server/pact-stub-server --file tests/Contract/pacts/my-family-tree-relationship-my-family-tree-user.json
I will got this error:
Copy code
2023-03-08T06:56:49.189486Z  INFO main pact_verifier::pact_broker: Fetching path '/' from pact broker
2023-03-08T06:56:49.189512Z ERROR main pact_stub_server: There were errors loading the pact files.
2023-03-08T06:56:49.189515Z ERROR main pact_stub_server:   - Invalid URL - relative URL without a base
Error: ExitCode(unix_exit_status(3))
I think stub server should load from the json file and ignore the env var
PACT_BROKER_BASE_URL
(and should not return that error). Is this a bug?
u
No, that environment var is used for the
--broker-url
parameter
It is the same as adding
--broker-url abc
t
I mean: • I didn't specify the
--broker-url
option manually, so I expect stub server didn't go to pact broker to look for pacts. • the env var
PACT_BROKER_BASE_URL
was set by Github/Gitlab for the
publishing pacts
feature after running consumer's contract tests. I didn't know that it will force stub server ignore
--file
option and look for pacts on pact broker instead. It's unexpected to me.
u
That's how clap works (the crate that does the CLI parsing). If the env var is set, it is turning on the option
t
Symfony Process has a feature to remove any environment variable from the process. I use that feature to remove
PACT_BROKER_BASE_URL
from
pact-stub-server
process, and it will load pact file I specified. All good for me.