{"record":{"id":"8a7b341bd27281c2","repo":"github/copilot-sdk","slug":"marshal-elicitation-schema-wrapper-for-property-q","errorCode":null,"errorMessage":"marshal elicitation schema wrapper for property %q: %w","messagePattern":"marshal elicitation schema wrapper for property %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/session.go","lineNumber":1229,"sourceCode":"\t\treturn nil, fmt.Errorf(\"elicitation schema property %q is nil\", name)\n\t}\n\tif rpcProperty, ok := property.(rpc.UIElicitationSchemaProperty); ok {\n\t\treturn rpcProperty, nil\n\t}\n\n\tdata, err := json.Marshal(property)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshal elicitation schema property %q: %w\", name, err)\n\t}\n\twrapperData, err := json.Marshal(struct {\n\t\tProperties map[string]json.RawMessage  `json:\"properties\"`\n\t\tType       rpc.UIElicitationSchemaType `json:\"type\"`\n\t}{\n\t\tProperties: map[string]json.RawMessage{name: data},\n\t\tType:       rpc.UIElicitationSchemaTypeObject,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshal elicitation schema wrapper for property %q: %w\", name, err)\n\t}\n\n\tvar rpcSchema rpc.UIElicitationSchema\n\tif err := json.Unmarshal(wrapperData, &rpcSchema); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode elicitation schema property %q: %w\", name, err)\n\t}\n\trpcProperty, ok := rpcSchema.Properties[name]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"decode elicitation schema property %q: property missing after conversion\", name)\n\t}\n\treturn rpcProperty, nil\n}\n\n// Confirm shows a confirmation dialog and returns the user's boolean answer.\n// Returns false if the user declines or cancels.\nfunc (ui *SessionUI) Confirm(ctx context.Context, message string) (bool, error) {\n\tif err := ui.session.assertElicitation(); err != nil {\n\t\treturn false, err","sourceCodeStart":1211,"sourceCodeEnd":1247,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/session.go#L1211-L1247","documentation":"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.","triggerScenarios":"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).","commonSituations":"Custom json.Marshaler implementations returning errors; corrupted property data after manual RawMessage manipulation; extremely unusual for plain maps/structs.","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"],"exampleFix":"// before\ntype P struct{ V io.Reader } // custom marshaler errors\n// after\ntype P struct{ V string `json:\"v\"` }","handlingStrategy":"validation","validationCode":"if _, err := json.Marshal(property); err != nil {\n    return fmt.Errorf(\"property unencodable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, err := ui.Elicitation(ctx, msg, schema)\nif err != nil && strings.Contains(err.Error(), \"marshal elicitation schema wrapper\") {\n    log.Printf(\"schema conversion failed: %v\", err)\n    return err\n}","preventionTips":["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"],"tags":["elicitation","schema","json"],"backgroundTag":"json-marshal-failed","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}