New request
#21164: Bug: "Invalid filter : taskTarget/noteTarget object doesn't have any 'targetLigacaoId' field" on Custom Objects
We'll provision a sandbox, run an agent against the issue, and open a draft PR. You can pull the branch and iterate from there.
Bug Description
When attempting to add tasks or notes to custom objects, the operation fails. A validation error is displayed stating that the target object does not contain the targetLigacaoId field.
Error messages:
Invalid filter : noteTarget object doesn't have any "targetLigacaoId" field.Invalid filter : taskTarget object doesn't have any "taskLigacaoId" field.
(Please add screenshots of the error appearing in the UI here)
Expected behavior
Users should be able to successfully add tasks and notes to custom objects without encountering filter validation errors. The application should correctly handle the relation mapping for custom targets, matching the behavior of standard Twenty objects.
Technical inputs
This issue specifically occurs with custom objects. When executing the same action on standard Twenty fields/objects (such as Companies, Opportunities, or Persons), the relationship works perfectly and no errors are thrown.
The frontend triggers a GraphQL query (FindManyTaskTargets) filtering by targetLigacaoId, but the backend responds with a BAD_USER_INPUT code because the field is missing from the custom object schema.
GraphQL Request Payload & Response
{
"request": {
"operationName": "FindManyTaskTargets",
"variables": {
"filter": {
"targetLigacaoId": {
"eq": "xpto"
}
},
"orderBy": [
{
"createdAt": "DescNullsFirst"
}
],
"limit": 200
},
"query": "query FindManyTaskTargets($filter: TaskTargetFilterInput, $orderBy: [TaskTargetOrderByInput], $lastCursor: String, $limit: Int, $offset: Int) {\n taskTargets(\n filter: $filter\n orderBy: $orderBy\n first: $limit\n after: $lastCursor\n offset: $offset\n ) {\n edges {\n node {\n __typename\n createdAt\n id\n task {\n __typename\n assigneeId\n bodyV2 {\n blocknote\n markdown\n __typename\n }\n createdAt\n createdBy {\n source\n workspaceMemberId\n name\n context\n __typename\n }\n deletedAt\n dueAt\n id\n position\n status\n taskTargets {\n edges {\n node {\n __typename\n createdAt\n createdBy {\n source\n workspaceMemberId\n name\n context\n __typename\n }\n deletedAt\n id\n position\n targetCompany {\n __typename\n domainName {\n primaryLinkUrl\n primaryLinkLabel\n secondaryLinks\n __typename\n }\n id\n name\n }\n targetCompanyId\n targetOpportunity {\n __typename\n id\n name\n }\n targetOpportunityId\n targetPerson {\n __typename\n avatarFile {\n fileId\n label\n extension\n url\n __typename\n }\n id\n name {\n firstName\n lastName\n __typename\n }\n }\n targetPersonId\n task {\n __typename\n id\n title\n }\n taskId\n updatedAt\n updatedBy {\n source\n workspaceMemberId\n name\n context\n __typename\n }\n }\n __typename\n }\n __typename\n }\n title\n updatedAt\n updatedBy {\n source\n workspaceMemberId\n name\n context\n __typename\n }\n }\n updatedAt\n }\n cursor\n __typename\n }\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n __typename\n }\n totalCount\n __typename\n }\n}"
},
"response": {
"data": {
"taskTargets": null
},
"errors": [
{
"message": "Object taskTarget doesn't have any \"targetLigacaoId\" field.",
"extensions": {
"subCode": "INVALID_ARGS_FILTER",
"userFriendlyMessage": "Invalid filter : taskTarget object doesn't have any \"targetLigacaoId\" field.",
"code": "BAD_USER_INPUT"
}
}
]
}
}
Frontend generates a non-existent targetLigacaoId filter for custom objects while the backend enforces strict schema validation.
- packages/twenty-front/src/modules/activities/tasks/hooks/useTaskTargets.ts
- packages/twenty-front/src/modules/activities/notes/hooks/useNoteTargets.ts
- packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts
- packages/twenty-server/src/engine/api/rest/core/query-runner/helpers/process-graphql-args.helper.ts