-
Notifications
You must be signed in to change notification settings - Fork 980
Open
Description
Problem
msggen has a UnionField class (model.py:369-400) designed to represent oneOf JSON schemas, but no generator in the pipeline can actually render it. As a result, every schema field that uses oneOf is manually overridden to a single type (usually ArrayField or PrimitiveField), silently dropping variants.
This means the typed APIs (cln-rpc, gRPC, Python) cannot express what the C implementation and JSON schema both support. For example, invoice.exposeprivatechannels accepts true, ["1x1x3"], or "1x1x3" in JSON-RPC, but cln-rpc only exposes Option<Vec<ShortChannelId>>.
Related: ElementsProject/lightning#8961
Root Cause
UnionField.from_js()has a constructor bug — does not passadded/deprecatedto__init__CompositeField.from_js()has nooneOfdetection — top-leveloneOffields hit the"type" not in ftype"warning and are skipped- No generator handles
UnionField— all 6 generators (rust.py,proto.py,convert.py,unconvert.py,grpc2py.py,notification.py) only dispatch onPrimitiveField,ArrayField,EnumField, andCompositeField - Traversal utilities skip
UnionField—patch.py,checks.py, and bothgather_subfieldsfunctions don't recurse into union variants
Because of (2)-(4), every oneOf field requires a manual override in model.py:537-560, and every override is lossy.
Affected Fields (18 schemas use oneOf)
| Override | Schema oneOf | What's Lost |
|---|---|---|
Invoice.exposeprivatechannels |
boolean | array[scid] | scid |
boolean and single scid variants |
Invoice.label (×5 methods) |
string | integer |
integer variant |
Datastore.key (×4 methods) |
array[string] | string |
single string variant |
Offer.amount |
msat_or_any | currency |
currency variant |
SetConfig.val |
string | integer | boolean |
integer and boolean variants |
Pay.exclude |
array[scid_dir | pubkey] |
pubkey variant (array-item oneOf) |
Fix
model.py: FixUnionField.from_js()constructor, addoneOfdetection inCompositeField.from_js()patch.py,checks.py: AddUnionFieldtraversalrust.py: Generate#[serde(untagged)]enumsproto.py: Generateoneofblocks with wrapper messages for array variantsconvert.py/unconvert.py: Generate bidirectionalFromimpls for union typesgrpc2py.py: GenerateWhichOneof()-based conversion- Remove 12 overrides that exist solely because
oneOfwas not handled
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels