fix: Container REST API — hostId ignored, containerStructures broken, and missing @Schema annotations
Open
@fmontes is already working on this.
Since Mar 9, 2026.
Team : Falcon
Type : Task
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
The Container REST API (/api/v1/containers) has three bugs discovered during AI agent integration testing via the OpenAPI spec:
Bug 1: hostId field is accepted but silently ignored
ContainerFormacceptshostIdand the OpenAPI spec advertises it- But
ContainerResource.saveNew()(line 779) andupdate()(line 874) never readcontainerForm.getHostId() - Both endpoints get the host from
WebAPILocator.getHostWebAPI().getCurrentHostNoThrow(request)instead - The
_copyendpoint has the same issue (line 1424) - Result: site assignment cannot be controlled via the API — containers always land on the current request's site
Bug 2: containerStructures causes Hibernate session error on POST and PUT
- Sending
containerStructuresarray in the request body causes HTTP 400 with a Hibernate error - Root cause: The Hibernate mapping (
DotCMSId.hbm.xml:457) usesunsaved-value=""on theidfield — if the client sends anidvalue, Hibernate tries an UPDATE on a non-existent row instead of INSERT - The
saveContainerStructures()method (ContainerAPIImpl.java:551) callsHibernateUtil.save()with these detached/misidentified objects - Workaround: use top-level
structureInode+codefields instead
Bug 3: ContainerForm has no @Schema annotations
- None of the fields on
ContainerFormor itsBuilderhave@Schemaannotations - The OpenAPI spec auto-generates with no descriptions, making it unclear that
friendlyNameis the "description" field - Fields like
hostIdandcontainerStructuresappear usable in the spec but are broken/ignored
Affected files
dotCMS/src/main/java/com/dotcms/rest/api/v1/container/ContainerResource.javadotCMS/src/main/java/com/dotcms/rest/api/v1/container/ContainerForm.javadotCMS/src/main/java/com/dotmarketing/portlets/containers/business/ContainerAPIImpl.javadotCMS/src/main/java/com/dotmarketing/beans/ContainerStructure.javadotCMS/src/main/resources/com/dotmarketing/beans/DotCMSId.hbm.xmldotCMS/src/main/webapp/WEB-INF/openapi/openapi.yaml
Acceptance Criteria
- POST/PUT
/api/v1/containersuseshostIdfrom the request body (when provided) to determine the container's site, falling back to the current request site if not set - POST/PUT
/api/v1/containerscorrectly savescontainerStructuressent in the request body without Hibernate errors -
ContainerFormfields have@Schemaannotations with descriptions (especiallyfriendlyNamedocumented as "description", andhostIddocumented with its behavior) - The generated OpenAPI spec accurately reflects which fields are functional
- Existing container creation/update flows (UI, integrations) continue to work
Root Cause Summary
| # | Issue | Root Cause Location | Category |
|---|---|---|---|
| 1 | hostId silently ignored |
ContainerResource.java:779,874,1424 — never reads containerForm.getHostId() |
Java bug (dead field) |
| 2 | containerStructures Hibernate error |
ContainerAPIImpl.java:551 + DotCMSId.hbm.xml:457 — unsaved-value="" treats JSON-supplied id as existing entity |
Java bug / Hibernate mapping |
| 3 | No @Schema on ContainerForm |
ContainerForm.java — field friendlyName serves as "description" but no annotations document this |
Missing documentation |
Priority
Medium
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.