Documentation cleanup and bugfixes

This commit is contained in:
2026-05-05 20:01:45 -05:00
parent 2b9658fb01
commit bf058a046e
10 changed files with 162 additions and 39 deletions

View File

@@ -117,6 +117,9 @@ func TestHandlerPostRunsSuccessWithExplicitProfileID(t *testing.T) {
if strings.Contains(w.Body.String(), secret) {
t.Fatalf("response leaked raw API key value: %s", w.Body.String())
}
if _, ok := resp["raw_model_output"]; ok {
t.Fatalf("expected raw_model_output to be omitted by default, got %#v", resp["raw_model_output"])
}
if r.last.PromptID != "prompt-1" {
t.Fatalf("expected request prompt_id prompt-1, got %q", r.last.PromptID)
@@ -265,7 +268,7 @@ func TestHandlerRawAPIKeyRejectedByStrictJSON(t *testing.T) {
}
}
func TestHandlerValidationFailureStillSuccess(t *testing.T) {
func TestHandlerValidationFailureStillSuccessAndRawOutputOptIn(t *testing.T) {
h := NewHandler(&fakeRunner{result: &domain.RunResult{
Artifact: domain.Artifact{Body: []byte("bad json")},
RawOutput: "bad json",
@@ -292,6 +295,24 @@ func TestHandlerValidationFailureStillSuccess(t *testing.T) {
if status, ok := validation["status"].(string); !ok || status != "failed" {
t.Fatalf("expected validation status=failed, got %#v", validation["status"])
}
if _, ok := resp["raw_model_output"]; ok {
t.Fatalf("expected raw_model_output omitted by default, got %#v", resp["raw_model_output"])
}
reqWithRaw := httptest.NewRequest(http.MethodPost, "/v1/runs", bytes.NewBufferString(`{"prompt_id":"p","inputs":{"x":{"type":"file","uri":"a"}},"include_raw_output":true}`))
wWithRaw := httptest.NewRecorder()
h.ServeHTTP(wWithRaw, reqWithRaw)
if wWithRaw.Code != http.StatusOK {
t.Fatalf("expected 200, got %d: %s", wWithRaw.Code, wWithRaw.Body.String())
}
var respWithRaw map[string]any
if err := json.Unmarshal(wWithRaw.Body.Bytes(), &respWithRaw); err != nil {
t.Fatalf("invalid JSON response: %v", err)
}
if got, ok := respWithRaw["raw_model_output"].(string); !ok || got != "bad json" {
t.Fatalf("expected raw_model_output to be included when requested, got %#v", respWithRaw["raw_model_output"])
}
}
func wrap(stage error, cause error) error {