Conversation
Greptile SummaryThis PR refactors the Twenty SDK client service by extracting the inline Twenty client template code into a separate file ( Changes:
Code quality suggestions:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 84187a5 |
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/twenty-sdk/src/cli/utilities/client/twenty-client-template.ts">
<violation number="1" location="packages/twenty-sdk/src/cli/utilities/client/twenty-client-template.ts:407">
P1: `setAuthorizationToken` overwrites `API_KEY_ENV_KEY` with a refreshed access token, corrupting a different credential type. An API key (`TWENTY_API_KEY`) is a static long-lived credential and should not be overwritten with an ephemeral access token. Only `APP_ACCESS_TOKEN_ENV_KEY` should be updated on token refresh.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/twenty-sdk/src/cli/utilities/client/twenty-client-template.ts
Outdated
Show resolved
Hide resolved
packages/twenty-sdk/src/cli/utilities/client/__tests__/clientServiceGeneratedClientAuth.test.ts
Show resolved
Hide resolved
packages/twenty-sdk/src/cli/utilities/client/twenty-client-template.ts
Outdated
Show resolved
Hide resolved
| expect(mockCreateOneNoteTarget).toHaveBeenCalledWith({ | ||
| noteId: fakeNoteId, | ||
| }); |
There was a problem hiding this comment.
Bug: The setAuthorizationToken method no longer updates the legacy API_KEY_ENV_KEY environment variable, which can cause authentication failures for integrations relying on it.
Severity: CRITICAL
Suggested Fix
In the setAuthorizationToken method within packages/twenty-sdk/src/cli/utilities/client/twenty-client-template.ts, re-add the line processEnvironment[API_KEY_ENV_KEY] = token; to ensure backward compatibility by updating both the new and legacy environment variables with the refreshed token.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location:
packages/twenty-front/src/modules/activities/hooks/__tests__/useOpenCreateActivityDrawer.test.tsx#L64-L66
Potential issue: The refactored `setAuthorizationToken` method in
`twenty-client-template.ts` no longer updates the `API_KEY_ENV_KEY` environment variable
upon token refresh. The previous implementation updated both `APP_ACCESS_TOKEN_ENV_KEY`
and `API_KEY_ENV_KEY` to maintain backward compatibility. The removal of the
`API_KEY_ENV_KEY` update means that any legacy integrations or parts of the system that
still rely on this variable will not receive the refreshed authentication token. This
will lead to authentication failures for those systems after a token refresh event.
|
Hey @ehconitin! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
|
Thanks @ehconitin for your contribution! |

No description provided.