Skip to content

[DEFECT] NPE when fetching content via content api with depth 3 and high limit #33645

Description

@dsilvam

Problem Statement

There are some times where the content api fails with a NPE when fetching content via the API when passing depth 3 and a high limit.

The following query failed a number of times in different days

api/content/render/false/depth/3/type/json/query/+contentType:Coupon%20+(conhost:af61f6d2-0d1d-4e98-a567-860eb29be277%20conhost:SYSTEM_HOST)%20+languageId:1%20+deleted:false%20+working:true%20+live:true/orderby/modDate%20desc/limit/30000

Two different types errors in the logs could be seen:

2025-10-09 02:51:46.340 | 00:51:46.339 WARN util.ContentUtils - null @ url:api/content/render/false/depth/3/type/json/query/+contentType:FranchiseInformation%20+(conhost:af61f6d2-0d1d-4e98-a567-860eb29be277%20conhost:SYSTEM_HOST)%20+languageId:1%20+deleted:false%20+working:true%20+live:true/orderby/modDate%20desc/limit/30000 \| lang:1 \| ip:xx.xx.xx.xx \| Admin:false \| start:10-07-2025 03:30:28 GMT

Which occurred 28 times between Oct 10 and Oct 11

2025-10-09 02:49:05.245 | 00:49:05.245 WARN util.ContentUtils - Cannot invoke "com.dotcms.contenttype.model.type.ContentType.hasStoryBlockFields()" because the return value of "com.dotmarketing.portlets.contentlet.model.Contentlet.getContentType()" is null @ url:GET/api/content/render/false/depth/3/type/json/query/+contentType:FranchiseInformation%20+(conhost:af61f6d2-0d1d-4e98-a567-860eb29be277%20conhost:SYSTEM_HOST)%20+languageId:1%20+deleted:false%20+working:true%20+live:true/orderby/modDate%20desc/limit/30000 \| lang:1 \| ip:xx.xx.xx.xx \| Admin:false \| start:10-08-2025 07:59:07 GMT

Which occurred 2 times on Oct 8 and 1 time on Oct 9.

It's been almost impossible to identify the cause so we need additional logging to understand why is this happening.

Additional reproduction observed (2026-06-05)
A new variant of this issue has been identified in production:

Content type: ServiceAreas — 0 published items, 472 items in Unpublished status
API query using +live:true is returning ~110 results unexpectedly
Returned results contain live:false in the JSON payload, contradicting the +live:true filter
Intermittently, the same query returns 0 results
Re-indexing ServiceAreas did not resolve the behaviour

Query used:
/api/content/render/false/depth/3/type/json/query/+contentType:serviceAreas%20+(conhost:af61f6d2-0d1d-4e98-a567-860eb29be277%20conhost:SYSTEM_HOST)%20+languageId:1%20+deleted:false%20+working:true%20+live:true/orderby/modDate%20desc/limit/30000

This suggests the index may not be correctly reflecting publish status, and the +live:true filter is not being honoured reliably. The intermittent 0-result response may point to a race condition or stale index state.

See ticket related:

Highly important -> https://helpdesk.dotcms.com/a/tickets/35794

https://helpdesk.dotcms.com/a/tickets/33726

Steps to Reproduce

This happened on a customer instance between Oct 8th and Oct 11th.

The query that produced the error was:
api/content/render/false/depth/3/type/json/query/+contentType:Coupon%20+(conhost:af61f6d2-0d1d-4e98-a567-860eb29be277%20conhost:SYSTEM_HOST)%20+languageId:1%20+deleted:false%20+working:true%20+live:true/orderby/modDate%20desc/limit/30000

Some of them with different contentTypes.

Acceptance Criteria

No NPE happening for the cases described above and have the expected content returned.

dotCMS Version

24.12.27_lts_v11

Severity

Medium - Some functionality impacted

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions