Skip to content

Commit 436e29f

Browse files
Copilotthebuilder
andcommitted
Remove legacy null culture behavior for empty cultures array
Co-authored-by: thebuilder <[email protected]>
1 parent d5d5ac5 commit 436e29f

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/umb-management-api/tools/document/__tests__/create-document.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ describe("create-document", () => {
9898
expect(cultures).toEqual(["da-DK", "en-US"]);
9999
});
100100

101-
it("should create a document with empty cultures array (null culture)", async () => {
102-
// Create document with empty cultures array - should behave like original
101+
it("should create a document with empty cultures array (auto-fetch behavior)", async () => {
102+
// Create document with empty cultures array - should behave same as no cultures parameter
103103
const docModel = {
104104
documentTypeId: ROOT_DOCUMENT_TYPE_ID,
105105
name: TEST_DOCUMENT_NAME,
@@ -115,8 +115,8 @@ describe("create-document", () => {
115115

116116
const item = await DocumentTestHelper.findDocument(TEST_DOCUMENT_NAME);
117117
expect(item).toBeDefined();
118-
// Should have single variant with null culture
119-
expect(item!.variants).toHaveLength(1);
120-
expect(item!.variants[0].culture).toBeNull();
118+
// Should fetch cultures and create variants (same as when cultures parameter is omitted)
119+
// The exact number of variants depends on available cultures in the test environment
120+
expect(item!.variants.length).toBeGreaterThanOrEqual(1);
121121
});
122122
});

src/umb-management-api/tools/document/post/create-document.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const createDocumentSchema = z.object({
1010
documentTypeId: z.string().uuid("Must be a valid document type type UUID"),
1111
parentId: z.string().uuid("Must be a valid document UUID").optional(),
1212
name: z.string(),
13-
cultures: z.array(z.string()).optional().describe("Array of culture codes. If not provided, will fetch available cultures from Umbraco. If empty array provided, will create without culture (null culture)."),
13+
cultures: z.array(z.string()).optional().describe("Array of culture codes. If not provided, will fetch available cultures from Umbraco."),
1414
values: z
1515
.array(
1616
z.object({
@@ -30,7 +30,6 @@ const CreateDocumentTool = CreateUmbracoTool(
3030
3131
If cultures parameter is provided, a variant will be created for each culture code.
3232
If cultures parameter is not provided, the tool will automatically fetch available cultures from Umbraco and create variants for all of them.
33-
If an empty cultures array is provided, a single variant with null culture will be created (original behavior).
3433
3534
Always follow these requirements when creating documents exactly, do not deviate in any way.
3635
@@ -641,8 +640,8 @@ const CreateDocumentTool = CreateUmbracoTool(
641640
// Determine cultures to use
642641
let culturesToUse: (string | null)[] = [];
643642

644-
if (model.cultures === undefined) {
645-
// If cultures not provided, fetch available cultures from Umbraco
643+
if (model.cultures === undefined || model.cultures.length === 0) {
644+
// If cultures not provided or empty array, fetch available cultures from Umbraco
646645
try {
647646
const cultureResponse = await client.getCulture({ take: 100 });
648647
culturesToUse = cultureResponse.items.map(culture => culture.name);
@@ -654,9 +653,6 @@ const CreateDocumentTool = CreateUmbracoTool(
654653
// If fetching cultures fails, fallback to null culture
655654
culturesToUse = [null];
656655
}
657-
} else if (model.cultures.length === 0) {
658-
// If empty array provided, use null culture (original behavior)
659-
culturesToUse = [null];
660656
} else {
661657
// Use provided cultures
662658
culturesToUse = model.cultures;

0 commit comments

Comments
 (0)