fix(02-03): expand expected placeholders after replay capture

Unquoted numeric id placeholders made recorded JSON illegal to parse.
Replay now recaptures, persists vars, expands the expected body, and
diffs against the live response.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-17 12:51:24 +02:00
parent 1ea3c59055
commit 591a0d4681
3 changed files with 79 additions and 1 deletions

View File

@@ -199,6 +199,26 @@ func expandRequest(req Request, store *Store) (Request, error) {
return out, nil
}
func expandResponse(resp Response, store *Store) (Response, error) {
out := resp
var err error
if resp.Headers != nil {
out.Headers = make(map[string]string, len(resp.Headers))
for k, v := range resp.Headers {
out.Headers[k], err = store.Expand(v)
if err != nil {
return Response{}, err
}
}
}
body, err := store.Expand(string(resp.Body))
if err != nil {
return Response{}, err
}
out.Body = Body(body)
return out, nil
}
// CaptureStep writes named values from the step into the store.
func CaptureStep(store *Store, step *Step) error {
if store == nil || step == nil || len(step.Capture) == 0 {