fix: an unknown redirect status, match or query is refused, not defaulted (WR-17)

The API, MCP, batches and the CSV import copied any value and Normalize
replaced it with the default, answering 201 for a 307 saved as a 301.
RedirectFields.Problems refuses values outside {301, 302, 410}, {exact,
pattern, regex} and {ignore, pass} with value_invalid; the import marks
such rows refused.
This commit is contained in:
2026-10-27 15:36:21 +01:00
parent c8e0961740
commit 24e6f384ca
6 changed files with 68 additions and 0 deletions

View File

@@ -126,6 +126,12 @@ func TestBatch(t *testing.T) {
if after := env.snapshot(t); after != before {
t.Fatalf("a refused batch wrote:\n%s", after)
}
coerced := env.mcp(t, http.MethodPost, "/_seo/api/v1/batch", agent, map[string]any{"changes": []any{
map[string]any{"op": "create_redirect", "redirect": map[string]any{"source": "/s307", "target": "/pages/a", "status": 307}},
}})
if coerced.Code != http.StatusUnprocessableEntity || !strings.Contains(coerced.Body.String(), `"status"`) {
t.Fatalf("batch with status 307 = %d %s, want 422 on status", coerced.Code, coerced.Body.String())
}
if rec := env.mcp(t, http.MethodPost, "/_seo/api/v1/batch", agent, map[string]any{"changes": []any{map[string]any{"op": "explode"}}}); rec.Code != http.StatusUnprocessableEntity {
t.Fatalf("unknown op = %d, want 422", rec.Code)
}