Skip to content

Commit 3403151

Browse files
donnyyungclaude
andauthored
fix: preserve language_presets locale code keys from case conversion (#65)
Locale codes like "pt-br" under language_presets are user-defined identifiers, not schema fields. Without this fix, they get incorrectly converted (pt-br → ptBr / pt_br) during push/pull, breaking the API. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 588a63f commit 3403151

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

src/__tests__/utils.test.ts

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,109 @@ describe("Utils", () => {
594594
});
595595
});
596596

597+
it("should preserve language_presets locale keys in toCamelCaseKeys", () => {
598+
const input = {
599+
conversation_config: {
600+
language_presets: {
601+
"pt-br": {
602+
overrides: {
603+
agent: {
604+
first_message: "Olá!"
605+
}
606+
}
607+
},
608+
"en": {
609+
overrides: {
610+
agent: {
611+
first_message: "Hello!"
612+
}
613+
}
614+
}
615+
}
616+
}
617+
};
618+
619+
const result = toCamelCaseKeys(input);
620+
621+
expect(result).toEqual({
622+
conversationConfig: {
623+
languagePresets: {
624+
"pt-br": { // preserved - locale code, NOT converted to "ptBr"
625+
overrides: {
626+
agent: {
627+
firstMessage: "Olá!" // converted - schema field
628+
}
629+
}
630+
},
631+
"en": { // preserved - locale code
632+
overrides: {
633+
agent: {
634+
firstMessage: "Hello!" // converted - schema field
635+
}
636+
}
637+
}
638+
}
639+
}
640+
});
641+
});
642+
643+
it("should preserve languagePresets locale keys in toSnakeCaseKeys", () => {
644+
const input = {
645+
conversationConfig: {
646+
languagePresets: {
647+
"pt-br": {
648+
overrides: {
649+
agent: {
650+
firstMessage: "Olá!"
651+
}
652+
}
653+
}
654+
}
655+
}
656+
};
657+
658+
const result = toSnakeCaseKeys(input);
659+
660+
expect(result).toEqual({
661+
conversation_config: {
662+
language_presets: {
663+
"pt-br": { // preserved - locale code, NOT converted to "pt_br"
664+
overrides: {
665+
agent: {
666+
first_message: "Olá!" // converted - schema field
667+
}
668+
}
669+
}
670+
}
671+
}
672+
});
673+
});
674+
675+
it("should maintain round-trip conversion symmetry for language_presets", () => {
676+
const original = {
677+
conversation_config: {
678+
language_presets: {
679+
"pt-br": {
680+
overrides: {
681+
agent: {
682+
first_message: "Olá!"
683+
}
684+
},
685+
first_message_translation: {
686+
source_hash: "test",
687+
text: "Olá!"
688+
}
689+
}
690+
}
691+
}
692+
};
693+
694+
const afterPush = toCamelCaseKeys(original);
695+
const afterPull = toSnakeCaseKeys(afterPush);
696+
697+
expect(afterPull).toEqual(original);
698+
});
699+
597700
it("should preserve workflow nodes keys in toCamelCaseKeys", () => {
598701
const input = {
599702
workflow: {

src/shared/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function toSnakeCaseKey(key: string): string {
123123
const PRESERVE_CHILD_KEYS = new Set([
124124
'request_headers', 'requestHeaders',
125125
'dynamic_variables', 'dynamicVariables',
126+
'language_presets', 'languagePresets',
126127
'nodes',
127128
'edges',
128129
]);

0 commit comments

Comments
 (0)