Skip to content

Conversation

@barw4
Copy link
Contributor

@barw4 barw4 commented Nov 6, 2025

🎫 Issue IBX-10936

Related PRs:

ibexa/core#676
https://github.com/ibexa/taxonomy/pull/382

Description:

Why?

The need is to create a possibility to fetch content type fields based on provided content type group identifiers and content type identifiers, please see the related Figma: https://www.figma.com/design/WkIyhysX3ZGSRwwxnPcFXE/-AI-Features--AI?node-id=8808-117516&t=50I4ptpZFht2TAps-0

As we don't have APIs for fetching field definitions, and we already have a service that allows fetching it using field expression: e.g. {Content}/{folder}/{name} the decision was to expose the ContentTypeFieldsByExpressionService to REST. Possible need: frontend requests vectorizable_fields configuration and provides the expression to backend, backend responds with field definition info objects.

REST

Summary

  • expose a REST controller that resolves content type field definitions from an expression by delegating to ContentTypeFieldsByExpressionServiceInterface
Method Path Consumes Produces
POST /api/ibexa/v2/content-type/load-field-definitions-from-expression application/vnd.ibexa.api.FieldDefinitionExpression+json (or +xml) application/vnd.ibexa.api.FieldDefinitionInfoList+json (or +xml)

Request Payload

{
  "FieldDefinitionExpression": {
    "expression": "{Content}/{folder}/{name}",
    "configuration": "vectorizable_fields" // Optional
  }
}

Example JSON Response

{
  "FieldDefinitions": {
    "_media-type": "application/vnd.ibexa.api.FieldDefinitionInfoList+json",
    "FieldDefinitionInfo": [
      {
        "_media-type": "application/vnd.ibexa.api.FieldDefinitionInfo+json",
        "id": "__FIXED_ID__",
        "identifier": "name",
        "position": 1,
        "names": {
          "value": [
            {
              "_languageCode": "eng-US",
              "#text": "Name"
            }
          ]
        }
      }
    ]
  }
}

In order to use configuration one needs to have the following configuration defined https://github.com/ibexa/taxonomy/pull/382

For QA:

Documentation:

Internal, NDR

@barw4 barw4 self-assigned this Nov 6, 2025
@barw4 barw4 added Feature New feature request Ready for review labels Nov 6, 2025
@barw4 barw4 requested a review from a team November 6, 2025 15:07
@barw4 barw4 changed the title IBX-9266: Implemented fetching field definitions from an expression IBX-10936: Implemented fetching field definitions from an expression Nov 6, 2025
@mnocon mnocon added Doc needed The changes require some documentation and removed Doc needed The changes require some documentation labels Nov 7, 2025
@mikadamczyk mikadamczyk requested a review from a team November 7, 2025 09:13
@barw4 barw4 requested review from a team, Steveb-p and mikadamczyk November 7, 2025 09:33
Copy link
Contributor

@konradoboza konradoboza left a comment

Choose a reason for hiding this comment

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

Apart from other remarks.

@barw4 barw4 requested a review from mikadamczyk November 7, 2025 19:29
@barw4 barw4 force-pushed the expression-parser-endpoint branch from 8ee52df to 0e365cc Compare November 14, 2025 09:20
@barw4 barw4 requested a review from Steveb-p November 17, 2025 09:09
$contentTypeFieldIds = $this->fieldsExtractor->extractFieldsFromExpression($expression);

$configuration = $configuration !== null
? $this->configResolver->getParameter("content_type_fields_by_expression.configurations.$configuration")
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is the location where LogicException happens?

This should be handled / validated properly, since in this case configuration is coming from REST query. External data should not be capable of triggering LogicExceptions. You can use any exception (like InvalidArgumentException), but definitely not this one.

@sonarqubecloud
Copy link

*
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
* @throws \Ibexa\AdminUi\Exception\FieldTypeExpressionParserException
* @throws \LogicException
Copy link
Contributor

Choose a reason for hiding this comment

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

This cannot be declared for the interface. It has to be a different type of exception, if needed.

Suggested change
* @throws \LogicException

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

Labels

Feature New feature request Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants