Commit b361d99
committed
RPC peers: emit empty arrays for descriptor collections, never omit them
`Recipe.getDescriptor()` on the Java side always returns a descriptor
whose collection-valued getters (`tags`, `options`, `preconditions`,
`recipeList`, `dataTables`, `maintainers`, `contributors`, `examples`)
are non-null. Callers across the ecosystem rely on that and iterate the
getters without null checks.
When a `RecipeDescriptor` is produced by a polyglot RPC peer, however,
the JSON those peers emit can omit empty collections — Jackson then
deserializes the corresponding fields as `null`, breaking every
downstream caller (e.g. `descriptor.getPreconditions().iterator()`).
Fix the Python and TypeScript peers to always emit every collection key,
even when empty. The C# peer was already correct: `RecipeDescriptorDto`
declares each list/set property with an `= []` initializer and
Newtonsoft serializes empty collections as `[]`, so the JSON it produces
already matches the contract.
Python (`rewrite/src/rewrite/rpc/server.py`):
Add `preconditions`, `maintainers`, `contributors`, `examples` as
empty lists in `_recipe_descriptor_to_dict`. (The Python `RecipeDescriptor`
dataclass doesn't model these fields yet, so they're hardcoded.)
TypeScript (`rewrite/src/recipe.ts`):
Extend the `RecipeDescriptor` interface with the four missing fields
and have `Recipe.descriptor()` populate them. Updates the existing
`recipe.test.ts` snapshot.1 parent c229022 commit b361d99
4 files changed
Lines changed: 60 additions & 6 deletions
File tree
- rewrite-javascript/rewrite
- src
- test
- rewrite-python/rewrite
- src/rewrite/rpc
- tests/rpc
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | | - | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
106 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
| |||
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
138 | | - | |
139 | 147 | | |
| 148 | + | |
| 149 | + | |
140 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
878 | 878 | | |
879 | 879 | | |
880 | 880 | | |
881 | | - | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
882 | 888 | | |
883 | 889 | | |
884 | 890 | | |
| |||
897 | 903 | | |
898 | 904 | | |
899 | 905 | | |
900 | | - | |
| 906 | + | |
901 | 907 | | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
902 | 912 | | |
903 | 913 | | |
904 | 914 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments