From 52f1f1501e834412ebaabfd7f9784d8752aed435 Mon Sep 17 00:00:00 2001 From: "daniel.solis" Date: Fri, 22 May 2026 16:13:29 -0600 Subject: [PATCH] fix(postman): fall back to English (id=1) when _getdefault returns invalid id (#35780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #35795 added a prerequest script to Workflow_Resource_Tests and GraphQLTests that calls GET /api/v2/languages/_getdefault to resolve a real language id. The script's existing guard accepted ANY non-falsy value — but in some test environments _getdefault returns the LANG__404 sentinel with id=-1. The script then stored -1 in defaultLanguageId, the test body sent "languageId": -1, and the server FK-failed on contentlet insert (Key (language_id)=(-1) is not present in table "language"). Observed in run 26312707306: GET /api/v2/languages/_getdefault [200 OK] defaultLanguageId = -1 ... ERROR: insert or update on table "contentlet" violates foreign key constraint "fk_contentlet_lang" This tightens the guard (id <= 0 also triggers the fallback) and falls back to English (id=1) — which is always present in dotCMS starter data. Network / auth errors still throw, only invalid-id responses fall back. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/main/resources/postman/GraphQLTests.json | 10 +++++++--- .../resources/postman/Workflow_Resource_Tests.json | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dotcms-postman/src/main/resources/postman/GraphQLTests.json b/dotcms-postman/src/main/resources/postman/GraphQLTests.json index 5369b0adefb..04b37a9c021 100644 --- a/dotcms-postman/src/main/resources/postman/GraphQLTests.json +++ b/dotcms-postman/src/main/resources/postman/GraphQLTests.json @@ -14878,9 +14878,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);", diff --git a/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json b/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json index f06e1a4722c..1f10295ecb8 100644 --- a/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json +++ b/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json @@ -19851,9 +19851,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);",