fix(postman): fall back to English (id=1) when _getdefault returns invalid id (#35780)#35817
fix(postman): fall back to English (id=1) when _getdefault returns invalid id (#35780)#35817dsolistorres wants to merge 1 commit into
Conversation
…valid id (#35780) 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) <noreply@anthropic.com>
|
Claude finished @dsolistorres's task in 1m 18s —— View job Review
Verdict: looks correct and minimal. The guard change ( Worth flagging (non-blocking)
Nits
|
…valid 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) <noreply@anthropic.com>
Summary
Follow-up to PR #35795. The prerequest script we added there accepts any non-falsy value from
GET /api/v2/languages/_getdefaultand stores it asdefaultLanguageId. In some test environments the endpoint returns the LANG__404 sentinel withid=-1, which our guard treated as valid. Test bodies then sent\"languageId\": -1and the server FK-failed on contentlet insert.Evidence from run 26312707306 (PR #35771)
The failing test (
Page API / Test DotAsset as titleImage / Create DotAsset image) haddefaultLanguageId = -1substituted into its body. Server's_getdefaultreturned the sentinel, our script blindly trusted it.Fix
Tighten the existing guard and add a fallback to English (
id=1) — always present in dotCMS starter data, matches the same approach as #35813:Network errors and non-200 responses still throw (no silent swallowing) — only invalid-id payloads fall back.
Scope
Workflow_Resource_Tests.json+GraphQLTests.json(both currently on main).Test plan
PR Test / Postman Tests - GraphQLandWorkflowshould pass even when_getdefaultreturns the sentinel.🤖 Generated with Claude Code