{"record":{"id":"42767a7af186550e","repo":"dapr/dapr","slug":"failed-to-marshal-s-w","errorCode":null,"errorMessage":"failed to marshal %s: %w","messagePattern":"failed to marshal (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/internal/loader/validate/validate.go","lineNumber":127,"sourceCode":"\treturn nil\n}\n\n// Validate checks the given resource against both the CRD's OpenAPI schema\n// constraints (enum, minLength, minItems, required, etc.) and any CEL\n// XValidation rules. The resource must be JSON-serializable. Returns nil if valid.\n// The context is passed to CEL validation so callers can cancel long-running\n// validation work (e.g. during shutdown or hot-reload storms).\nfunc (v *Validator) Validate(ctx context.Context, resource any) error {\n\tv.initOnce.Do(func() {\n\t\tv.initErr = v.init()\n\t})\n\tif v.initErr != nil {\n\t\treturn fmt.Errorf(\"%s validator initialization failed; validation could not be completed: %w\", v.name, v.initErr)\n\t}\n\n\traw, err := json.Marshal(resource)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal %s: %w\", v.name, err)\n\t}\n\n\tvar obj any\n\tif err := json.Unmarshal(raw, &obj); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal %s: %w\", v.name, err)\n\t}\n\n\t// Validate against OpenAPI schema (enum, minLength, minItems, etc.).\n\terrs := apivalidation.ValidateCustomResource(field.NewPath(\"\"), obj, v.schemaValidator)\n\n\t// Validate against CEL XValidation rules (if any are defined in the CRD).\n\tcelErrs, _ := v.celValidator.Validate(\n\t\tctx,\n\t\tfield.NewPath(\"\"),\n\t\tnil,\n\t\tobj,\n\t\tnil,\n\t\tcelconfig.RuntimeCELCostBudget,","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/dapr/dapr/blob/74ad41702745709bb15fe2114ff693b8c59bc3cc/pkg/internal/loader/validate/validate.go#L109-L145","documentation":"Error \"failed to marshal %s: %w\" thrown in dapr/dapr.","triggerScenarios":"Thrown at pkg/internal/loader/validate/validate.go:127 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"74ad41702745709bb15fe2114ff693b8c59bc3cc","analyzedAt":"2026-08-16T04:22:26.543Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}