{"record":{"id":"87fce6b79e84a28b","repo":"github/copilot-sdk","slug":"marshal-elicitation-schema-property-q-w","errorCode":null,"errorMessage":"marshal elicitation schema property %q: %w","messagePattern":"marshal elicitation schema property %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/session.go","lineNumber":1219,"sourceCode":"\n\treturn rpc.UIElicitationSchema{\n\t\tProperties: properties,\n\t\tRequired:   append([]string(nil), schema.Required...),\n\t\tType:       rpc.UIElicitationSchemaTypeObject,\n\t}, nil\n}\n\nfunc toRPCUIElicitationSchemaProperty(name string, property any) (rpc.UIElicitationSchemaProperty, error) {\n\tif property == nil {\n\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 {","sourceCodeStart":1201,"sourceCodeEnd":1237,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/session.go#L1201-L1237","documentation":"For non-rpc property definitions, toRPCUIElicitationSchemaProperty json.Marshal's the property value before wrapping it in an object schema. If the value cannot be marshaled (e.g. contains channels, funcs, or cyclic references), the library returns this error naming the property. It indicates the caller supplied a property definition that is not JSON-representable.","triggerScenarios":"Passing an ElicitationSchema property whose value contains unmarshalable Go values (func, chan, cyclic pointer) instead of a plain map/struct or rpc.UIElicitationSchemaProperty.","commonSituations":"Embedding closures or callbacks in schema definitions by mistake; cyclic data structures built for defaults; using custom types without JSON tags in ways that fail encoding.","solutions":["Remove non-JSON-serializable values (funcs, channels, cycles) from the property definition","Use plain map[string]any / tagged structs for property definitions","Convert the property to rpc.UIElicitationSchemaProperty directly to bypass marshaling","Test json.Marshal on your schema before invoking the UI method"],"exampleFix":"// before\nprops := map[string]any{\"cb\": func() {}} // unmarshalable\n// after\nprops := map[string]any{\"cb\": map[string]any{\"type\": \"string\"}}","handlingStrategy":"validation","validationCode":"for name, p := range schema.Properties {\n    if _, err := json.Marshal(p); err != nil {\n        return fmt.Errorf(\"property %q not JSON-encodable: %w\", name, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"res, err := ui.Elicitation(ctx, msg, schema)\nif err != nil && strings.Contains(err.Error(), \"marshal elicitation schema property\") {\n    return fmt.Errorf(\"property is not JSON-serializable: %w\", err)\n}","preventionTips":["Keep property definitions to JSON-safe types (maps, structs, primitives)","Avoid funcs/channels/cycles in schema values","Prefer rpc.UIElicitationSchemaProperty for programmatic schemas"],"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"}