﻿# garak REST adapters: a successful HTTP response may still contain no scored answer

Validate garak REST response extraction against the real endpoint envelope, preserving skipped or malformed generations instead of mistaking transport success for evaluation coverage.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-garak-rest-generator-response-extraction-coverage/
Language: en

## Validate the returned envelope first

A REST endpoint can accept a request and return a valid JSON envelope while the scanner extracts the wrong field. The inspected [REST generator implementation](https://github.com/NVIDIA/garak/blob/main/garak/generators/rest.py) distinguishes raw response text from configured JSON extraction. Determine where the actual answer resides before running a large scan. An HTTP success code and parseable JSON do not establish that a detector received the text produced by the evaluated application.

## Inspect extraction under the installed version

The current implementation validates the configured response field or JSONPath and distinguishes an extraction configuration that has never succeeded from a later response-shape mismatch. Inspect that behavior in the installed release rather than assuming every mismatch becomes a normal empty answer. A provider may return different envelopes for errors, refusals or streaming responses. Exercise the actual response variants so the adapter's treatment remains visible and does not silently redefine the measured population.

## Preserve generation alignment

The [generator base contract](https://github.com/NVIDIA/garak/blob/main/garak/generators/base.py) checks returned generation counts and supports unavailable outputs. Keep those positions aligned with downstream observations. Dropping an unextractable result and shifting later answers can associate a detector verdict with the wrong request. A missing measurement should retain its identity and reason. It is not automatically equivalent to an application refusing the request, returning an empty message or satisfying the probe's intended requirement.

## Distinguish response layers in the report

The [Attempt model](https://github.com/NVIDIA/garak/blob/main/garak/attempt.py) stores prompt histories, outputs and detector results. Retain enough diagnostic evidence to connect the endpoint envelope to the extracted message and its judged output position. This is especially important when an application wraps a model answer in additional metadata. Evaluating the entire envelope instead of the answer can expose a detector to unrelated strings, while extracting a convenience field can omit the content the test was intended to assess.

## Check benign response variants before scale

Use fixtures for a valid answer, a missing field and a documented application error. Confirm whether each becomes a scored response, an explicit failure or an unavailable generation under the selected adapter. The guides to [JSONL counting units](/journal/fg2-garak-jsonl-attempt-status-generation-denominators/) and [transformed output contracts](/journal/fg2-promptfoo-output-transform-hierarchy-measured-artifact/) provide related controls. Report actual extracted and judged coverage alongside transport outcomes, preserving the distinction between an endpoint that responded and an evaluation that obtained usable evidence about the intended answer.
