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

@@ -89,6 +89,10 @@ func TestCSVTransfer(t *testing.T) {
}
// Refusals of the file as a whole.
odd := env.mcpExpect(t, http.StatusOK, http.MethodPost, "/_seo/api/v1/import", agent, map[string]any{"dataset": "redirects", "csv": "source;match;target;query\n/g1;glob;/x;ignore\n/g2;exact;/x;keep\n", "delimiter": ";", "dry_run": true})
if s := summary(t, odd); s["refused"] != 2 {
t.Fatalf("import with an unknown match and query = %v, want 2 refused rows (WR-17)", odd)
}
rec := env.mcp(t, http.MethodPost, "/_seo/api/v1/import", agent, map[string]any{"dataset": "redirects", "csv": "target;status\n/x;301\n", "delimiter": ";", "dry_run": true})
if rec.Code != http.StatusUnprocessableEntity || !strings.Contains(rec.Body.String(), `"error":"missing_column"`) || !strings.Contains(rec.Body.String(), "source") {
t.Fatalf("missing column = %d %s", rec.Code, rec.Body.String())