Skip to content

Added ContentTypeOwnedBySomeoneElseException for content type draft owned by another user#770

Open
bnowak wants to merge 3 commits into
5.0from
content-type-owned-by-someone-else-exception
Open

Added ContentTypeOwnedBySomeoneElseException for content type draft owned by another user#770
bnowak wants to merge 3 commits into
5.0from
content-type-owned-by-someone-else-exception

Conversation

@bnowak

@bnowak bnowak commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-XXXXX

Description

ContentTypeService::loadContentTypeDraft() threw a generic NotFoundException with the message
'The content type is owned by someone else' when a draft existed but was owned by a different user,
carrying a long-standing @todo Use another exception when user of draft is someone else.

Consumers had no way to distinguish that ownership case from a genuinely missing draft other than by
matching the exception message, which is fragile — the message can change here and silently break
those consumers.

This PR introduces a dedicated Ibexa\Core\Repository\ContentType\Exception\ContentTypeOwnedBySomeoneElseException
(extending Ibexa\Core\Base\Exceptions\NotFoundException) and throws it from loadContentTypeDraft(),
resolving the @todo. Callers can now branch on the exception type via instanceof.

The exception passes the same 'The content type is owned by someone else' description to its parent,
so the resulting message is unchanged and existing catch (NotFoundException $e) blocks keep working.

Motivation

Raised in review of the MCP get_content_type_draft tool:
https://github.com/ibexa/mcp/pull/14#discussion_r3466283486

@bnowak bnowak marked this pull request as ready for review June 29, 2026 10:17
@bnowak bnowak requested a review from a team June 29, 2026 10:20
@bnowak bnowak force-pushed the content-type-owned-by-someone-else-exception branch from f9c5a30 to e4a2d8e Compare July 3, 2026 10:22

@alongosz alongosz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to see some minimal test coverage for the new exception, but +1.

@micszo micszo self-assigned this Jul 6, 2026
@micszo micszo force-pushed the content-type-owned-by-someone-else-exception branch from e4a2d8e to f330a79 Compare July 6, 2026 09:16
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants