From 5b07856a2081fbfd1765b05cb09734531a495000 Mon Sep 17 00:00:00 2001 From: "daniel.solis" Date: Fri, 22 May 2026 15:59:22 -0600 Subject: [PATCH 1/2] fix(postman): pass explicit language in AI Search Related by identifier (#35780) The Search/Search Related by identifier test posts to /api/v1/ai/search/related without a `language` field, so the server (SearchResource.relatedByPost) falls back to APILocator.getLanguageAPI().getDefaultLanguage().getId(). In test environments where the default is the LANG__404 sentinel (id=-1), this returns -1 and findContentletByIdentifier(id, -1) returns 404, failing the test with "expected response to have status code 200 but got 404". Follow-up to #35795 which fixed the same class of failure in Workflow_Resource_Tests and GraphQLTests. AI was intentionally out of scope in that PR. This change: - Adds a top-level prerequest script that resolves the default language id via GET /api/v2/languages/_getdefault once per Newman run, throws on any resolution error (matches the pattern shipped in #35795 v2). - Patches the failing test body to send `"language": {{defaultLanguageId}}` (note: the server reads AiKeys.LANGUAGE = "language", not "languageId"). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../postman/AI.postman_collection.json | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/dotcms-postman/src/main/resources/postman/AI.postman_collection.json b/dotcms-postman/src/main/resources/postman/AI.postman_collection.json index b21bc3bed0b..1800bc13e0a 100644 --- a/dotcms-postman/src/main/resources/postman/AI.postman_collection.json +++ b/dotcms-postman/src/main/resources/postman/AI.postman_collection.json @@ -2370,7 +2370,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"identifier\": \"{{identifier}}\",\n \"fieldVar\": \"seo\"\n}", + "raw": "{\n \"identifier\": \"{{identifier}}\",\n \"fieldVar\": \"seo\",\n \"language\": {{defaultLanguageId}}\n}", "options": { "raw": { "language": "json" @@ -3813,7 +3813,37 @@ "type": "text/javascript", "packages": {}, "exec": [ - "" + "// [issue #35780] Resolve default language id once per run so tests that depend on", + "// the server-side default-language do not break when getDefaultLanguage() returns", + "// the LANG__404 sentinel (id=-1) in a fresh test environment.", + "if (!pm.environment.get('defaultLanguageId')) {", + " const serverURL = pm.environment.get('serverURL');", + " const username = pm.environment.get('user');", + " const password = pm.environment.get('password');", + " const basicAuth = Buffer.from(`${username}:${password}`).toString('base64');", + " pm.sendRequest({", + " url: `${serverURL}/api/v2/languages/_getdefault`,", + " method: 'GET',", + " header: {", + " 'accept': 'application/json',", + " 'Authorization': `Basic ${basicAuth}`", + " }", + " }, function (err, response) {", + " if (err) {", + " throw new Error('Could not resolve default language: ' + err);", + " }", + " if (response.code !== 200) {", + " throw new Error('Could not resolve default language: HTTP ' + response.code);", + " }", + " const body = response.json();", + " const id = body && body.entity && body.entity.id;", + " if (!id) {", + " throw new Error('Could not resolve default language: entity.id missing in response');", + " }", + " pm.environment.set('defaultLanguageId', id);", + " console.log('defaultLanguageId = ' + id);", + " });", + "}" ] } }, From 229c28caf2f0f09dba2f2c4c40c34099f02ffd93 Mon Sep 17 00:00:00 2001 From: "daniel.solis" Date: Fri, 22 May 2026 16:17:00 -0600 Subject: [PATCH 2/2] fix(postman): fall back to English (id=1) when _getdefault returns invalid id Same fallback shipping for Workflow_Resource_Tests + GraphQLTests in #35817. Applied here so AI is consistent before this PR merges. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../main/resources/postman/AI.postman_collection.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dotcms-postman/src/main/resources/postman/AI.postman_collection.json b/dotcms-postman/src/main/resources/postman/AI.postman_collection.json index 1800bc13e0a..55b0750aca7 100644 --- a/dotcms-postman/src/main/resources/postman/AI.postman_collection.json +++ b/dotcms-postman/src/main/resources/postman/AI.postman_collection.json @@ -3836,9 +3836,13 @@ " throw new Error('Could not resolve default language: HTTP ' + response.code);", " }", " const body = response.json();", - " const id = body && body.entity && body.entity.id;", - " if (!id) {", - " throw new Error('Could not resolve default language: entity.id missing in response');", + " let id = body && body.entity && body.entity.id;", + " if (!id || id <= 0) {", + " // _getdefault can return the LANG__404 sentinel (id=-1) in fresh", + " // test environments. Fall back to English (id=1), which is always", + " // present in dotCMS starter data. See issue #35780.", + " console.log('Default language returned invalid id (' + id + '), falling back to English (id=1)');", + " id = 1;", " }", " pm.environment.set('defaultLanguageId', id);", " console.log('defaultLanguageId = ' + id);",