Skip to content

Conversation

@rjvelazco
Copy link
Contributor

@rjvelazco rjvelazco commented Jan 26, 2026

This PR fixes: #34300

Cleanup: Remove container variantId usage and use page-level variantId

Problem

The codebase was attempting to extract variantId from container objects via container?.parentPermissionable?.variantId, but this property no longer exists after PR #32890. This resulted in variantId always being undefined when used in container operations.

Additionally, containers don't actually have variantId - it's a page-level concept, not a container-level one. The /api/v1/page/copyContent endpoint expects the page-level variantId in the DotTreeNode payload, not a container's variantId.

Changes

  1. Removed variantId from getContainersData function (libs/sdk/uve/src/lib/dom/dom.utils.ts)

    • Removed the TODO comment and code attempting to extract variantId from parentPermissionable.variantId
    • This property no longer exists in the API response
  2. Removed variantId from EditableContainerData interface (libs/sdk/types/src/lib/editor/public.ts)

    • Removed the optional variantId?: string property since containers don't have variantId
  3. Updated getCurrentTreeNode to use page-level variantId (libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.ts)

    • Changed from using container.variantId to store.$variantId() which provides the page-level variantId
    • This ensures the correct variantId is sent to the /api/v1/page/copyContent endpoint
  4. Made ContainerPayload.variantId optional (libs/portlets/edit-ema/portlet/src/lib/shared/models.ts)

    • Changed from variantId: string to variantId?: string with documentation explaining containers don't have variantId
  5. Updated tests (libs/portlets/edit-ema/portlet/src/lib/store/features/editor/withEditor.spec.ts)

    • Updated test expectations to verify page-level variantId is used
    • Added test cases to ensure container variantId is ignored

Impact

  • Fixes incorrect API calls: The /api/v1/page/copyContent endpoint now receives the correct page-level variantId instead of undefined
  • Removes dead code: Eliminates code attempting to access a non-existent property
  • Improves code clarity: Makes it explicit that variantId is a page-level concept, not container-level
  • No breaking changes: ContainerPayload.variantId is now optional, maintaining backward compatibility

Testing

  • Updated unit tests to verify getCurrentTreeNode uses page-level variantId from store.$variantId()
  • Added test cases to ensure container variantId is properly ignored
  • All existing tests pass

Related

  • Related to issue: Issue #34300
  • Follows up on: PR #32890 which removed parentPermissionable from container API responses

…-parentpermissionable-for-container-variantid
@rjvelazco rjvelazco enabled auto-merge January 26, 2026 20:43
…issionable-for-container-variantid' of https://github.com/dotCMS/core into issue-34300-spike-sdk-re-visit-dependency-on-parentpermissionable-for-container-variantid
…-parentpermissionable-for-container-variantid
…issionable-for-container-variantid' of https://github.com/dotCMS/core into issue-34300-spike-sdk-re-visit-dependency-on-parentpermissionable-for-container-variantid
@semgrep-code-dotcms-test
Copy link

Legal Risk

The following dependencies were released under a license that
has been flagged by your organization for consideration.

Recommendation

While merging is not directly blocked, it's best to pause and consider what it means to use this license before continuing. If you are unsure, reach out to your security team or Semgrep admin to address this issue.

MPL-2.0

@rjvelazco rjvelazco closed this Jan 27, 2026
auto-merge was automatically disabled January 27, 2026 15:49

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[SPIKE] SDK: Re-visit Dependency on parentPermissionable for Container variantId

5 participants