Skip to content

Probe your mocks for requests they should refuse

Before you begin

Plan
Included in Pro and Team. How plans and limits work
Role
Editor or higher to start a probe and Viewer or higher to read the result.
You need
  • A project with an OpenAPI contract and a plan that checks requests against it
  • The [CLI](/guides/cli/install-and-connect/) and a token that can create preview environments

A mock that answers every POST /orders with 201 also answers the one with no sku. A probe shows whether that happens. It takes one request your contract accepts, changes it one thing at a time into a request the contract rejects, and sends each to its own fresh copy of your project’s mocks.

  1. Save a request your contract accepts, as JSON:

    {
    "method": "POST",
    "url": "/orders",
    "headers": { "Content-Type": "application/json" },
    "body": "{\"sku\":\"a\",\"qty\":2}"
    }
  2. Run the probe:

    Terminal window
    mockhub openapi probe --env staging --request order.json
  3. Read what each change got.

MockHub removes a required field or parameter, changes a primitive type, leaves an enum, crosses a simple numeric or length bound, and changes the content type. It offers a change only when the contract rejects it at the place it changed, so a change is never invalid for some other reason. The request you send must itself be valid, or the probe refuses to start.

Result Meaning
counterexample A mock answered a success to that changed request.
rejected The copy refused it, for example because no mock matched.
inconclusive The answer could not be attributed, such as a server error.

The command exits 0 when no counterexample was found, 1 when one was, and 2 when the result is inconclusive. Each row names the mock and the response that answered, never a value from your request. The result also records the project the copies came from, the contract revision checked against with its digest, and the version of MockHub’s request check. It does not change once the probe has finished, and it expires with the rest of the run’s evidence.

“No counterexample found in N probes” is the strongest thing a probe says. It is not a proof that every invalid request is refused.

Each probe runs in its own copy of your project’s mocks, so nothing carries over from one to the next, and your project is not touched. A copy sends no webhook, applies no chaos profile, forwards nothing to your upstream and does not enforce the contract. Credentials in your request are not copied, and neither are saved fixtures, so a mock that matches on an Authorization header does not serve the baseline and the probe is inconclusive.

  • A probe covers one operation and at most ten changes, and at most one fewer than the preview environments your plan allows at once.
  • The baseline must be served with a success by a mock, or every change is inconclusive.
  • The changed request is the one the CLI sends. MockHub observes that it arrived, its status and the mock that answered.
  • An assistant reads a result with get_request_probe; it cannot send the probe.

Report a problem with this page