# Reproduce a client bug

[← Record & Replay](/docs/record-and-replay) · [Compare agent versions](/docs/record-and-replay/compare-agent-versions)

Use one fixed synthetic order response to expose a client formatter defect, check the correction against the same contract, then keep a reviewed HTTP response and application assertion together for your own reproduction.

> **Example boundary:** The downloads are an authored synthetic consumer packet. They are not a Gostly import format, capture, replay receipt or report of a real customer incident. The local commands make no network requests and do not call Gostly.

## Downloads

- [Response cases (JSON)](/examples/reproduce-api-bug/order-bug-packet.json)
- [Client check (ES module)](/examples/reproduce-api-bug/check-order-view.mjs)
- [Packet instructions (README)](/examples/reproduce-api-bug/README.md)

Save all three files in one directory. The packet contains GET /orders/order_demo_001; its synthetic 200 response has an empty delivery_date. The original formatter throws, while the corrected view keeps the order and shows that the estimate is unavailable.

## Prerequisites

- A current Node.js release.
- The three downloaded files saved together; no package installation or credentials are needed.
- For the follow-on HTTP workflow only: an application build, a test that reaches the affected code, and an HTTP exchange you are allowed to capture or a reviewed, sanitized HAR file.

## 1. Run the original client and keep its failing result

From the directory holding the downloaded files, run the broken variant. It is expected to exit with status 1 because the original formatter cannot produce a view for the empty delivery date.

```sh
node check-order-view.mjs broken
# Expected: the regression cases do not all match; exit 1.
```

The checker evaluates each response against the packet's declared expectation. The broken run is evidence of the authored code defect only; it does not exercise a browser, application server, network path or Gostly replay.

## 2. Check the correction against the same response cases

Run the fixed variant without changing the packet. It should match all declared cases and exit 0:

```sh
node check-order-view.mjs fixed
# Expected: all declared cases pass; exit 0.
```

The controls require the corrected formatter to preserve a valid date and order ID; reject malformed or impossible dates, a missing date, a wrong ID, an HTTP error and an invalid total; and display an unavailable estimate for the explicit empty-string or null cases.

## 3. Carry the case into your own HTTP reproduction

For a transport- or parser-related defect, retain the smallest allowed exchange that exposes it. Review and sanitize a source HAR before import, or record permitted traffic in LEARN. Build the library, confirm the intended service and MOCK mode, then inspect the returned status, body and the `src` member of the `X-Gostly-Behavior` response header to identify the serving path. Keep the same client assertion against the original and corrected application revisions, plus a normal control.

Record the request shape, response status and selected body, library/service identity, client revision, starting application state, and observed outcome. Re-create database, session and client-timer state in your own test harness where needed; a recorded response does not capture the whole application.

Continue with [recording in LEARN](/docs/record-and-replay#record-in-learn), [replaying in MOCK](/docs/record-and-replay#replay-in-mock), or the [HAR preparation guide](/docs/seeding/har#source-file).

## Expected checks and limits

- Same packet and assertions for broken and fixed clients; the original fails and the correction passes.
- A valid date still renders; an always-unavailable shortcut does not satisfy the normal control.
- The example accepts date-only YYYY-MM-DD values. It does not define timestamp, time-zone, estimate freshness or estimate truth rules.
- The local packet validates a small consumer view model. It does not establish HTTP routing, authentication, import behavior, replay fidelity, DOM rendering, provider behavior or the whole application workflow.
- Keep secrets and personal data out of shared recordings. Local replay bodies and imported source files have separate review and retention boundaries; see the [security model](/docs/security-model).

