dotCMS / dotCMS/core

Date field default value now is not honored when content is created via the Workflow / Save APIs (only the legacy Struts edit path handles it)

Open
#35,665 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OKR : Customer Support Team : Maintenance
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Problem Statement

When a Date, Date‑and‑Time, or Time field is configured with now as its default value, the legacy Struts edit‑content path resolves it to new Date(). The newer save path used by the Workflow Action REST API (/api/v1/workflow/actions/{id}/fire) does not — it routes through FieldHandlerStrategyFactory.dateStrategy(...) → DateUtil.convertDate("now", formats), which has no special case for now, fails parsing, and the error gets swallowed by the catch in ESContentletAPIImpl.setDefaultValues(...) as:

ERROR ... ESContentletAPIImpl - Can not set the default value: now to the field: <fieldVar>, on the ct: <ContentType>

Net effect: the contentlet is saved with that date field empty/null, even though the content type says the default should be the current timestamp. There's no error returned to the API caller — only a log line — so it's silent data loss from the caller's perspective.

Steps to Reproduce
  • Create a content type (e.g. CommunityEngagement) with a Date or Date‑and‑Time field (e.g. signatureDate).
  • Set the field's Default Value to now and save the content type. (Validation accepts it — see com.dotcms.contenttype.util.FieldUtil#validDate.)
  • Fire a workflow action that creates a new contentlet of this type via REST, without providing signatureDate in the request body
  • Tail the dotCMS log.

https://drive.google.com/file/d/1RiGBELmRHCckijhZFh3rfWVo8YLitH29/view?usp=sharing

Acceptance Criteria
  • Firing a workflow action that creates a contentlet of a content type with a Date/Date‑and‑Time/Time field defaulted to now, where the field is not in the request body, persists the current server timestamp on that field.
  • Same behavior via direct ContentletAPI#checkin and the Contentlet REST API.
  • Existing behavior for literal date strings ("2026-05-21", ISO 8601, etc.) is unchanged.
  • New unit test on FieldHandlerStrategyFactory#parseDate covers the "now" (and "NOW") cases.
dotCMS Version

latest
26.05.11-01

Severity

Medium - Some functionality impacted

Links

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with FieldHandlerStrategyFactory#parseDate and DateUtil.convertDate, then inspect ESContentletAPIImpl#setDefaultValues and the workflow, ContentletAPI#checkin, and Contentlet REST entry points. Add coverage for "now" and "NOW" while preserving literal date parsing, and verify that omitted defaulted date fields persist the current server timestamp through each stated API path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.