You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have really enjoyed building Kube manifests in TypeScript using jk for my home cluster and personal projects, but I think there is an issue with the deep merge function:
Bug Description
Attempting to perform a merge via deep when one of the child keys is an empty array results in the following error:
@jkcfg/std/internal/flatbuffers.js:686
while (i < s.length) {
^
TypeError: Cannot read property 'length' of undefined
at flatbuffers.Builder.createString (@jkcfg/std/internal/flatbuffers.js:686:22)
at write (@jkcfg/std/write.js:37:28)
at print (@jkcfg/std/write.js:65:5)
at /Users/shimmerjs/dev/megazord/kubernetes/dist/jkcfg-merge-bug.js:6:1
import { print } from '@jkcfg/std';
import { deep } from '@jkcfg/std/merge';
import { $INLINE_JSON } from 'ts-transformer-inline-file';
const input1 = $INLINE_JSON('./input-1.json');
const input2 = $INLINE_JSON('./input-2.json');
const result = deep(input1, input2);
print(result, {});
export default [
{
path: 'jkcfg-merg.json',
value: result,
},
];
Note that I am using the ts-transformer-inline-file transformer and the ttsc project to run tsc with plugins. Here is the resultant JS file for running without needing to set that up:
Run jk generate to cause the error (ignore the file paths, I wrote the script in my kube workspace for convenience):
jk generate -o kubernetes/generated -i kubernetes/ kubernetes/dist/jkcfg-merge-bug.js
@jkcfg/std/internal/flatbuffers.js:686
while (i < s.length) {
^
TypeError: Cannot read property 'length' of undefined
at flatbuffers.Builder.createString (@jkcfg/std/internal/flatbuffers.js:686:22)
at write (@jkcfg/std/write.js:37:28)
at print (@jkcfg/std/write.js:65:5)
at /Users/shimmerjs/dev/megazord/kubernetes/dist/jkcfg-merge-bug.js:6:1
Module (kubernetes/dist/jkcfg-merge-bug.js) has not been loaded
To double check my assumptions on what a standard deep merge would produce, I wrote the same script using lodash-es to verify the result:
I have really enjoyed building Kube manifests in TypeScript using
jk
for my home cluster and personal projects, but I think there is an issue with thedeep
merge function:Bug Description
Attempting to perform a merge via
deep
when one of the child keys is an empty array results in the following error:Reproduction Steps
input-1.json
:input-2.json
:Note that I am using the
ts-transformer-inline-file
transformer and thettsc
project to runtsc
with plugins. Here is the resultant JS file for running without needing to set that up:jk generate
to cause the error (ignore the file paths, I wrote the script in my kube workspace for convenience):To double check my assumptions on what a standard deep merge would produce, I wrote the same script using
lodash-es
to verify the result:Which produced this result:
Versions:
jk
binary:The text was updated successfully, but these errors were encountered: