github/copilot-sdk · error
marshal elicitation schema wrapper for property
Error message
marshal elicitation schema wrapper for property %q: %w
What it means
After marshaling an individual property, the function wraps it as {properties:{name:...}, type:"object"} and marshals that wrapper struct. Failure here means the wrapper itself could not be encoded, which in practice indicates a deeply broken property value or an environment-level encoding problem, since the wrapper only holds json.RawMessage and a constant type. The error names the offending property.
Solutions
- Inspect the wrapped error for the root marshal cause
- Replace custom json.Marshaler implementations on property types with plain tagged structs
- Rebuild the property definition from primitive map/struct data
- Marshal the property to json.RawMessage yourself and validate before calling
Example fix
// before
type P struct{ V io.Reader } // custom marshaler errors
// after
type P struct{ V string `json:"v"` } Defensive patterns
Strategy: validation
Validate before calling
if _, err := json.Marshal(property); err != nil {
return fmt.Errorf("property unencodable: %w", err)
} Try / catch
res, err := ui.Elicitation(ctx, msg, schema)
if err != nil && strings.Contains(err.Error(), "marshal elicitation schema wrapper") {
log.Printf("schema conversion failed: %v", err)
return err
} Prevention
- Use plain structs/maps for property definitions
- Avoid custom json.Marshaler implementations that can error
- Round-trip test your schema through json.Marshal before calls
When it happens
Trigger: toRPCUIElicitationSchemaProperty reaching the wrapper json.Marshal step with a value whose earlier encoding produced something inconsistent, or an exotic marshaler failure (e.g. unsupported underlying writer state, cyclic data escaping earlier checks).
Common situations: Custom json.Marshaler implementations returning errors; corrupted property data after manual RawMessage manipulation; extremely unusual for plain maps/structs.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- marshal elicitation schema property
- decode elicitation schema property
- failed to unmarshal response
- failed to unmarshal arguments into %T
- invalid hook input
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/8a7b341bd27281c2.
Report an issue: GitHub.
Appendix: source
Thrown at go/session.go:1229
return nil, fmt.Errorf("elicitation schema property %q is nil", name)
}
if rpcProperty, ok := property.(rpc.UIElicitationSchemaProperty); ok {
return rpcProperty, nil
}
data, err := json.Marshal(property)
if err != nil {
return nil, fmt.Errorf("marshal elicitation schema property %q: %w", name, err)
}
wrapperData, err := json.Marshal(struct {
Properties map[string]json.RawMessage `json:"properties"`
Type rpc.UIElicitationSchemaType `json:"type"`
}{
Properties: map[string]json.RawMessage{name: data},
Type: rpc.UIElicitationSchemaTypeObject,
})
if err != nil {
return nil, fmt.Errorf("marshal elicitation schema wrapper for property %q: %w", name, err)
}
var rpcSchema rpc.UIElicitationSchema
if err := json.Unmarshal(wrapperData, &rpcSchema); err != nil {
return nil, fmt.Errorf("decode elicitation schema property %q: %w", name, err)
}
rpcProperty, ok := rpcSchema.Properties[name]
if !ok {
return nil, fmt.Errorf("decode elicitation schema property %q: property missing after conversion", name)
}
return rpcProperty, nil
}
// Confirm shows a confirmation dialog and returns the user's boolean answer.
// Returns false if the user declines or cancels.
func (ui *SessionUI) Confirm(ctx context.Context, message string) (bool, error) {
if err := ui.session.assertElicitation(); err != nil {
return false, errView on GitHub (pinned to cd8cf15dc3)