fix(import): standardize error message formatting for file server directive handling

This commit is contained in:
GitHub Actions
2026-01-31 22:39:00 +00:00
parent 2253bf36b4
commit 38596d9dff

View File

@@ -367,7 +367,7 @@ func (h *ImportHandler) Upload(c *gin.Context) {
// Return 400 but include preview + warning so callers (and E2E) can render
// the same preview UX while still signaling an error status.
c.JSON(http.StatusBadRequest, gin.H{
"error": "File server directives are not supported for import or no sites/hosts found in your Caddyfile",
"error": "File server directives are not supported for import or no sites/hosts found in your Caddyfile",
"warning": "File server directives are not supported for import or no sites/hosts found in your Caddyfile",
"session": gin.H{"id": sid, "state": "transient", "source_file": tempPath},
"preview": result,
@@ -563,7 +563,7 @@ func (h *ImportHandler) UploadMulti(c *gin.Context) {
// preview shape while the HTTP status indicates an error.
middleware.GetRequestLogger(c).WithField("mainCaddyfile", util.SanitizeForLog(filepath.Base(mainCaddyfile))).Warn("Import UploadMulti: parsed routes were file_server-only and not importable")
c.JSON(http.StatusBadRequest, gin.H{
"error": "File server directives are not supported for import or no sites/hosts found in your Caddyfile",
"error": "File server directives are not supported for import or no sites/hosts found in your Caddyfile",
"warning": "File server directives are not supported for import or no sites/hosts found in your Caddyfile",
"session": gin.H{"id": sid, "state": "transient", "source_file": mainCaddyfile},
"preview": result,