Skip to content

BUG: PUT /api/v1/page/copyContent returns 404 but successfully copies content when variantId is empty string #34473

@zJaaal

Description

@zJaaal

Problem Statement

The PUT /api/v1/page/copyContent endpoint returns a 404 error response but still successfully copies the content when variantId is provided as an empty string. This creates a misleading situation where the HTTP status suggests failure but the operation actually succeeds. This impacts API consumers who rely on status codes for error handling and may lead to incorrect retry logic or error reporting in client applications.

Steps to Reproduce

# Make a PUT request with empty variantId
curl -X PUT /api/v1/page/copyContent \
  -H "Content-Type: application/json" \
  -d '{
    "containerId": "//demo.dotcms.com/application/containers/default/",
    "contentId": "2e5d54e6-7ea3-4d72-8577-b8731b206ca0",
    "pageId": "1ef9be0e-7610-4c69-afdb-d304c8aabfac",
    "personalization": "dot:default",
    "relationType": "1",
    "treeOrder": "0",
    "variantId": ""
  }'

Expected: Success response (200 OK) with content copied
Actual: 404 error response BUT content is still successfully copied

Screen.Recording.2026-01-30.at.5.15.06.PM-1.mov

Acceptance Criteria

  • Empty string variantId is handled the same as null/missing variantId
  • API returns success status code (200 OK) when content is successfully copied with empty variantId
  • Default variant is used when variantId is empty, null, or not provided
  • Add validation to prevent misleading error responses
  • Add unit and integration tests covering this edge case

dotCMS Version

Current/Latest (please verify specific version if known)

Severity

Medium - Some functionality impacted

Links

NA

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Next Sprint

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions