anomalyco/sst · error

failed to create DNS record, status: %d, response: %s

Error message

failed to create DNS record, status: %d, response: %s

What it means

This fallback error is returned when the Cloudflare API indicates failure (non-2xx status or success:false) but the response contains no structured errors entries the library can extract. It includes the HTTP status code and the raw response body so the developer can diagnose from the payload itself.

Source

Thrown at pkg/server/resource/cloudflare-dns-record.go:178

				// Check if message contains "already exists" regardless of error code
				if strings.Contains(strings.ToLower(cfError.Message), "already exists") {
					return "existing-record", nil
				}
			}
		}
		
		// If not an "already exists" error, return the error information
		errorMsgs := []string{}
		for _, cfError := range apiResponse.Errors {
			errorMsgs = append(errorMsgs, fmt.Sprintf("%s", cfError.Message))
		}
		
		if len(errorMsgs) > 0 {
			return "", fmt.Errorf("Cloudflare API error: %s", strings.Join(errorMsgs, "; "))
		}
		
		// If we couldn't determine a specific error, return the raw response
		return "", fmt.Errorf("failed to create DNS record, status: %d, response: %s", resp.StatusCode, string(body))
	}
	
	// Success - return the record ID
	return apiResponse.Result.Id, nil
}

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Inspect the status code and body embedded in the error message
  2. If status 429, back off and retry later; reduce concurrent record creation
  3. If 401/403, rotate or fix the API token and its zone permissions
  4. If 5xx, check the Cloudflare status page and retry after the incident
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight rate/auth sanity check before bulk record creation
resp, _ := http.Get("https://api.cloudflare.com/client/v4/zones/" + zoneID)
// 429 or 5xx here predicts this failure; back off before deploying

Try / catch

_, err := record.Create(input, &out)
if err != nil && strings.Contains(err.Error(), "failed to create DNS record, status: 429") {
    time.Sleep(backoff) // exponential backoff, then retry
    _, err = record.Create(input, &out)
}

Prevention

When it happens

Trigger: Cloudflare responds with failure but an empty errors array — e.g. HTTP 401/403 auth failures with an unexpected body shape, 429 rate-limit responses, 5xx Cloudflare outages, or HTML/text bodies that still unmarshal (empty struct) but carry no error codes.

Common situations: Rate limiting (429) during bulk DNS record creation; expired API token returning an auth HTML page; Cloudflare incident/outage returning 5xx with minimal JSON; a reverse proxy returning an empty or plain-text error body.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/034668b4cdbf7715. Report an issue: GitHub.