fix(advanced-filter): exclude many-to-one relations from relation target picker

The backend supports a single-hop relation traversal. If the user picked
a many-to-one relation field as the target, the dispatcher would
substitute the target id into fieldMetadataId and recurse — the inner
call has relationTargetFieldMetadataId set to null, so it falls through
to the per-type RELATION case which expects a UUID list, not a primitive
value. The UI offered a traversal that the backend silently demoted to
filter-by-id.

Filter many-to-one fields out of the target list so only one-hop
traversals can be composed.
This commit is contained in:
Félix Malfait
2026-05-15 13:05:21 +02:00
parent a23ab663bc
commit 203f72116a

View File

@@ -62,9 +62,17 @@ export const AdvancedFilterRelationTargetFieldSelectMenu = ({
? sourceFieldMetadataItem.relation.targetObjectMetadata.id
: null;
const { filterableFieldMetadataItems: relationTargetFields } =
const { filterableFieldMetadataItems: allTargetFields } =
useFilterableFieldMetadataItems(targetObjectMetadataId ?? '');
// The backend supports a single hop only. Exclude many-to-one relations
// from the target list so the user can't compose multi-hop traversals
// (e.g. Person → Company → ParentCompany) that the dispatcher would
// collapse back to a filter-by-id on the intermediate relation.
const relationTargetFields = allTargetFields.filter(
(field) => !isManyToOneRelationField(field),
);
if (
!isDefined(sourceFieldMetadataItem) ||
!isManyToOneRelationField(sourceFieldMetadataItem)