Task: Figure out why the request is not executing correctly via n8n
Figure out why the request is not executing correctly via n8n
The situation is pretty classic in nature, but that doesn't automatically make it very simple, because this falls into the category of logical errors rather than technical ones.
The symptoms are as follows: directly through the GraphQL API, the request works correctly and data is returned, but from n8n it does not. And this is very strange, because by design the API should not depend on where the request is executed from. Yet here there are no errors, but the response comes back as an empty array. That is, it's not an error, it's simply the absence of data. And this categorically violates the established principles.
Ворклоги
That's right. Here is the beauty:
if (currentUser && !currentUser.sudo) {
result.createdById = currentUser.id
}
What was the AI thinking when it coded something like that? That's where the magic came from: the agent executes the timers request, and gets an empty array in response. I execute the exact same request, and I get data. I remove the authorization token, meaning I execute the request anonymously — the data is there too, meaning no special security policies are configured (nor should they be, because this is public data). And then it hardcodes a condition that if you are not authorized, you get everything, but if you are authorized and not sudo, then you only get your own data. In other words, the same request with the same data returns a different set of data depending on the circumstances. If this AI had hands, I would break them off.
Прописал сразу два запроса в одном
query timers {
me {
id
}
timers(orderBy: { createdAt: desc }, take: 10) {
id
startedAt
stoppedAt
Task {
id
title
content
projectId
WorkLogs {
id
content
}
}
}
}
Результат:
[
{
"data": {
"me": {
"id": "cmkpoyglm0000qm0ope3f11"
},
"timers": []
}
}
]
Вот это и есть странно. То есть данные пользователя получает, а таймеры нет. Предполагаю, что ИИ-агент где-то завайбкодил какое-то ненужное условие.