@@ -5,6 +5,7 @@ package framework
55
66import (
77 "context"
8+ "fmt"
89
910 "github.com/hashicorp/terraform-plugin-framework/action"
1011 aschema "github.com/hashicorp/terraform-plugin-framework/action/schema"
@@ -304,13 +305,17 @@ func newWrappedAction(inner action.Action, opts wrappedActionOptions) action.Act
304305
305306func (w * wrappedAction ) Metadata (ctx context.Context , request action.MetadataRequest , response * action.MetadataResponse ) {
306307 // This method does not call down to the inner action.
308+ fmt .Printf ("DEBUG: wrappedAction.Metadata() called, setting TypeName to: %s\n " , w .opts .typeName )
307309 response .TypeName = w .opts .typeName
308310}
309311
310312func (w * wrappedAction ) Schema (ctx context.Context , request action.SchemaRequest , response * action.SchemaResponse ) {
313+ fmt .Printf ("DEBUG: wrappedAction.Schema() called for action: %s\n " , w .opts .typeName )
314+
311315 ctx , diags := w .opts .bootstrapContext (ctx , nil , w .meta )
312316 response .Diagnostics .Append (diags ... )
313317 if response .Diagnostics .HasError () {
318+ fmt .Printf ("DEBUG: wrappedAction.Schema() bootstrap context failed for %s\n " , w .opts .typeName )
314319 return
315320 }
316321
@@ -320,20 +325,42 @@ func (w *wrappedAction) Schema(ctx context.Context, request action.SchemaRequest
320325 }
321326 response .Diagnostics .Append (interceptedHandler (w .opts .interceptors .actionSchema (), f , w .meta )(ctx , & request , response )... )
322327
328+ fmt .Printf ("DEBUG: wrappedAction.Schema() after interceptors, schema type: %T\n " , response .Schema )
329+
323330 // Validate the action's model against the schema.
324331 if v , ok := w .inner .(framework.ActionValidateModel ); ok {
332+ fmt .Printf ("DEBUG: wrappedAction.Schema() action implements ActionValidateModel for %s\n " , w .opts .typeName )
325333 if schema , ok := response .Schema .(aschema.UnlinkedSchema ); ok {
334+ fmt .Printf ("DEBUG: wrappedAction.Schema() schema is UnlinkedSchema with %d attributes for %s\n " , len (schema .Attributes ), w .opts .typeName )
326335 response .Diagnostics .Append (v .ValidateModel (ctx , & schema )... )
327336 if response .Diagnostics .HasError () {
337+ fmt .Printf ("DEBUG: wrappedAction.Schema() model validation failed for %s\n " , w .opts .typeName )
328338 response .Diagnostics .AddError ("action model validation error" , w .opts .typeName )
329339 return
330340 }
341+ fmt .Printf ("DEBUG: wrappedAction.Schema() model validation succeeded for %s\n " , w .opts .typeName )
331342 } else {
343+ fmt .Printf ("DEBUG: wrappedAction.Schema() schema is NOT UnlinkedSchema, got %T for %s\n " , response .Schema , w .opts .typeName )
332344 response .Diagnostics .AddError ("unsupported action schema type" , w .opts .typeName )
333345 }
334346 } else {
347+ fmt .Printf ("DEBUG: wrappedAction.Schema() action does NOT implement ActionValidateModel for %s\n " , w .opts .typeName )
335348 response .Diagnostics .AddError ("missing framework.ActionValidateModel" , w .opts .typeName )
336349 }
350+
351+ fmt .Printf ("DEBUG: wrappedAction.Schema() completed for %s, has errors: %t\n " , w .opts .typeName , response .Diagnostics .HasError ())
352+
353+ // Final debug: show what we're actually returning
354+ if ! response .Diagnostics .HasError () {
355+ if schema , ok := response .Schema .(aschema.UnlinkedSchema ); ok {
356+ fmt .Printf ("DEBUG: wrappedAction.Schema() FINAL SCHEMA for %s:\n " , w .opts .typeName )
357+ fmt .Printf ("DEBUG: Description: %s\n " , schema .Description )
358+ fmt .Printf ("DEBUG: Attributes (%d):\n " , len (schema .Attributes ))
359+ for name , attr := range schema .Attributes {
360+ fmt .Printf ("DEBUG: - %s: %T\n " , name , attr )
361+ }
362+ }
363+ }
337364}
338365
339366func (w * wrappedAction ) Invoke (ctx context.Context , request action.InvokeRequest , response * action.InvokeResponse ) {
0 commit comments