dapr/dapr · error

failed to marshal %s: %w

Error message

failed to marshal %s: %w

What it means

Error "failed to marshal %s: %w" thrown in dapr/dapr.

Source

Thrown at pkg/internal/loader/validate/validate.go:127

	return nil
}

// Validate checks the given resource against both the CRD's OpenAPI schema
// constraints (enum, minLength, minItems, required, etc.) and any CEL
// XValidation rules. The resource must be JSON-serializable. Returns nil if valid.
// The context is passed to CEL validation so callers can cancel long-running
// validation work (e.g. during shutdown or hot-reload storms).
func (v *Validator) Validate(ctx context.Context, resource any) error {
	v.initOnce.Do(func() {
		v.initErr = v.init()
	})
	if v.initErr != nil {
		return fmt.Errorf("%s validator initialization failed; validation could not be completed: %w", v.name, v.initErr)
	}

	raw, err := json.Marshal(resource)
	if err != nil {
		return fmt.Errorf("failed to marshal %s: %w", v.name, err)
	}

	var obj any
	if err := json.Unmarshal(raw, &obj); err != nil {
		return fmt.Errorf("failed to unmarshal %s: %w", v.name, err)
	}

	// Validate against OpenAPI schema (enum, minLength, minItems, etc.).
	errs := apivalidation.ValidateCustomResource(field.NewPath(""), obj, v.schemaValidator)

	// Validate against CEL XValidation rules (if any are defined in the CRD).
	celErrs, _ := v.celValidator.Validate(
		ctx,
		field.NewPath(""),
		nil,
		obj,
		nil,
		celconfig.RuntimeCELCostBudget,

View on GitHub (pinned to 74ad417027)

When it happens

Trigger: Thrown at pkg/internal/loader/validate/validate.go:127 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dapr/dapr@74ad417027 (2026-08-16). Data as JSON: /api/errors/42767a7af186550e. Report an issue: GitHub.