Remove incidental HTTP error wording expectations

This commit is contained in:
2026-11-26 01:02:06 +00:00
parent 3308fbcf48
commit 7690511483
2 changed files with 25 additions and 23 deletions

View File

@@ -3,14 +3,20 @@
Reviewed 2026-11-25 at `a949f23a87dc581e6beff400f440e09afcb23969`, against Reviewed 2026-11-25 at `a949f23a87dc581e6beff400f440e09afcb23969`, against
the nine stages in [implementation.md](implementation.md) and the accepted the nine stages in [implementation.md](implementation.md) and the accepted
[remediation target](audit-remediation.md). Changes reviewed begin after [remediation target](audit-remediation.md). Changes reviewed begin after
`6beddde`. Both findings below remain open; no fixes were implemented by this `6beddde`. The review itself implemented no fixes; subsequent remediation is
review. recorded by the completion markers below.
## 1. Non-Generation HTTP Errors Still Pin Noncontractual Sentences (P3) ## 1. Non-Generation HTTP Errors Still Pin Noncontractual Sentences (P3)
**Status: complete.** Removed complete-sentence expectations from the HTTP error
mapping table while retaining status/code/precedence, usable-message, and
private-cause checks. Normal and race-enabled full suites, vet, build, formatting,
and whitespace checks passed. The harmless artifact-error rewording overlay now
passes the full mapping table. Runtime messages are unchanged.
**Type:** incomplete stage 5 test cleanup; unnecessary test-level contract. **Type:** incomplete stage 5 test cleanup; unnecessary test-level contract.
**Location:** `TestHandlerPublicErrorMapping`, especially the conditional at **Location:** `TestHandlerPublicErrorMapping` in
[handler_test.go:1747](../../internal/adapter/http/handler_test.go#L1747). [handler_test.go](../../internal/adapter/http/handler_test.go).
The revised table exempts only `llm_failed` from exact message comparison. The revised table exempts only `llm_failed` from exact message comparison.
Artifact, profile, prompt, capacity, and other rows still require complete Artifact, profile, prompt, capacity, and other rows still require complete

View File

@@ -1696,29 +1696,28 @@ func TestHandlerPublicErrorMapping(t *testing.T) {
err error err error
status int status int
code string code string
message string
avoidCause string avoidCause string
}{ }{
{name: "prompt not found", err: promptkit.ErrPromptNotFound, status: http.StatusNotFound, code: "prompt_not_found", message: "prompt definition not found"}, {name: "prompt not found", err: promptkit.ErrPromptNotFound, status: http.StatusNotFound, code: "prompt_not_found"},
{name: "prompt load", err: wrap(promptkit.ErrPromptLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "prompt_load_failed", message: "failed to load prompt definition", avoidCause: "read failed"}, {name: "prompt load", err: wrap(promptkit.ErrPromptLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "prompt_load_failed", avoidCause: "read failed"},
{name: "missing profile/default", err: wrap(promptkit.ErrProfileRequired, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "profile_required", message: "profile_id is required when prompt default_profile is not set"}, {name: "missing profile/default", err: wrap(promptkit.ErrProfileRequired, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "profile_required"},
{name: "profile not found", err: promptkit.ErrProfileNotFound, status: http.StatusNotFound, code: "profile_not_found", message: "execution profile not found"}, {name: "profile not found", err: promptkit.ErrProfileNotFound, status: http.StatusNotFound, code: "profile_not_found"},
{name: "profile load", err: wrap(promptkit.ErrProfileLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "profile_load_failed", message: "failed to load execution profile", avoidCause: "read failed"}, {name: "profile load", err: wrap(promptkit.ErrProfileLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "profile_load_failed", avoidCause: "read failed"},
{name: "api key env missing", err: wrap(promptkit.ErrAPIKeyEnvMissing, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "api_key_env_missing", message: "api_key_env is set but the environment variable is missing"}, {name: "api key env missing", err: wrap(promptkit.ErrAPIKeyEnvMissing, promptkit.ErrInvalidRequest), status: http.StatusBadRequest, code: "api_key_env_missing"},
{name: "invalid request", err: promptkit.ErrInvalidRequest, status: http.StatusBadRequest, code: "invalid_request", message: "invalid run request"}, {name: "invalid request", err: promptkit.ErrInvalidRequest, status: http.StatusBadRequest, code: "invalid_request"},
{name: "file denied", err: ErrFileNotAllowed, status: http.StatusBadRequest, code: "artifact_not_allowed", message: "file input artifact is not allowed"}, {name: "file denied", err: ErrFileNotAllowed, status: http.StatusBadRequest, code: "artifact_not_allowed"},
{name: "file outside root", err: ErrFileOutsideRoot, status: http.StatusBadRequest, code: "artifact_not_allowed", message: "file input artifact is not allowed"}, {name: "file outside root", err: ErrFileOutsideRoot, status: http.StatusBadRequest, code: "artifact_not_allowed"},
{name: "file too large", err: ErrFileTooLarge, status: http.StatusRequestEntityTooLarge, code: "artifact_too_large", message: "file input artifact is too large"}, {name: "file too large", err: ErrFileTooLarge, status: http.StatusRequestEntityTooLarge, code: "artifact_too_large"},
{name: "file too large with broad category", err: errors.Join(ErrFileTooLarge, promptkit.ErrInvalidRequest, promptkit.ErrArtifactLoad), status: http.StatusRequestEntityTooLarge, code: "artifact_too_large", message: "file input artifact is too large"}, {name: "file too large with broad category", err: errors.Join(ErrFileTooLarge, promptkit.ErrInvalidRequest, promptkit.ErrArtifactLoad), status: http.StatusRequestEntityTooLarge, code: "artifact_too_large"},
{name: "artifact", err: wrap(promptkit.ErrArtifactLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "artifact_read_failed", message: "failed to read input artifact", avoidCause: "read failed"}, {name: "artifact", err: wrap(promptkit.ErrArtifactLoad, fmt.Errorf("read failed")), status: http.StatusBadRequest, code: "artifact_read_failed", avoidCause: "read failed"},
{name: "prompt render", err: wrap(promptkit.ErrPromptRender, fmt.Errorf("render failed")), status: http.StatusBadRequest, code: "prompt_render_failed", message: "failed to render prompt", avoidCause: "render failed"}, {name: "prompt render", err: wrap(promptkit.ErrPromptRender, fmt.Errorf("render failed")), status: http.StatusBadRequest, code: "prompt_render_failed", avoidCause: "render failed"},
{name: "capacity", err: &promptkit.CapacityError{BackendID: "private-backend"}, status: http.StatusServiceUnavailable, code: "capacity_exceeded", message: "model backend capacity is exhausted", avoidCause: "private-backend"}, {name: "capacity", err: &promptkit.CapacityError{BackendID: "private-backend"}, status: http.StatusServiceUnavailable, code: "capacity_exceeded", avoidCause: "private-backend"},
{name: "llm", err: wrap(promptkit.ErrLLMGenerate, fmt.Errorf("llm failed")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "llm failed"}, {name: "llm", err: wrap(promptkit.ErrLLMGenerate, fmt.Errorf("llm failed")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "llm failed"},
{name: "transport", err: wrap(promptkit.ErrTransport, fmt.Errorf("private transport detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private transport detail"}, {name: "transport", err: wrap(promptkit.ErrTransport, fmt.Errorf("private transport detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private transport detail"},
{name: "malformed response", err: wrap(promptkit.ErrMalformedResponse, fmt.Errorf("private response detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private response detail"}, {name: "malformed response", err: wrap(promptkit.ErrMalformedResponse, fmt.Errorf("private response detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private response detail"},
{name: "retry exhaustion", err: wrap(promptkit.ErrRetriesExhausted, fmt.Errorf("private provider detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private provider detail"}, {name: "retry exhaustion", err: wrap(promptkit.ErrRetriesExhausted, fmt.Errorf("private provider detail")), status: http.StatusBadGateway, code: "llm_failed", avoidCause: "private provider detail"},
{name: "retry exhaustion value", err: fmt.Errorf("generation: %w", &promptkit.RetryExhaustedError{}), status: http.StatusBadGateway, code: "llm_failed"}, {name: "retry exhaustion value", err: fmt.Errorf("generation: %w", &promptkit.RetryExhaustedError{}), status: http.StatusBadGateway, code: "llm_failed"},
{name: "validation runtime", err: wrap(promptkit.ErrValidation, fmt.Errorf("validator broke")), status: http.StatusInternalServerError, code: "validation_runtime_failed", message: "validation runtime failed", avoidCause: "validator broke"}, {name: "validation runtime", err: wrap(promptkit.ErrValidation, fmt.Errorf("validator broke")), status: http.StatusInternalServerError, code: "validation_runtime_failed", avoidCause: "validator broke"},
} }
for _, tc := range tests { for _, tc := range tests {
@@ -1744,9 +1743,6 @@ func TestHandlerPublicErrorMapping(t *testing.T) {
if !ok || strings.TrimSpace(message) == "" { if !ok || strings.TrimSpace(message) == "" {
t.Fatalf("expected a usable message, got %#v", errBody["message"]) t.Fatalf("expected a usable message, got %#v", errBody["message"])
} }
if tc.code != "llm_failed" && message != tc.message {
t.Fatalf("expected message %q, got %#v", tc.message, errBody["message"])
}
if tc.avoidCause != "" && strings.Contains(w.Body.String(), tc.avoidCause) { if tc.avoidCause != "" && strings.Contains(w.Body.String(), tc.avoidCause) {
t.Fatalf("expected response to avoid leaking cause details, got %s", w.Body.String()) t.Fatalf("expected response to avoid leaking cause details, got %s", w.Body.String())
} }