fix(slack): use environment id for slack connection id with legacy fallback#5559
fix(slack): use environment id for slack connection id with legacy fallback#5559
Conversation
…llback Renaming an environment broke Slack alerts because the connection id was built using the environment name. Switch to environment id (stable) for new installations and add a fallback to the legacy name-based id for existing ones. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…isconnect Only fall back to legacy name-based connection id when the error is specifically unknown_connection, not on any failure. Also handle disconnect for legacy name-based connections by retrying with the old format on 404. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TBonnin
left a comment
There was a problem hiding this comment.
lgtm. I don't think this endpoint has any integration tests yet. Might be a good time to add some :)
| this.integrationKey, | ||
| adminRes.environment.id | ||
| ); | ||
| if (!slackConnectionResult.success && slackConnectionResult.error?.type === 'unknown_connection') { |
There was a problem hiding this comment.
isn't !slackConnectionResult.success redundant?
There was a problem hiding this comment.
Yeps good point! let me remove it!
…tests
- Fix getEnvironment fallback condition from !connectionConfig to
!connectionConfig['incoming_webhook.channel'] since getConnectionConfig
always returns {} on miss, never null
- Remove redundant !slackConnectionResult.success check in slack.service.ts
- Add integration tests for GET /api/v1/environments/current covering
auth, env param enforcement, basic data, and both slack connection ID formats
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@TBonnin @rossmcewan thanks for the review, Ive added some new integration tests and thanks to that Ive caught a bug that I was not aware of! A new review would be very appreciate it! |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
No issues found; changes look solid and align with the review focus.
Status: No Issues Found | Risk: Low
Review Details
📁 7 files reviewed | 💬 0 comments
Instruction Files
├── .claude/
│ ├── agents/
│ │ └── nango-docs-migrator.md
│ └── skills/
│ ├── agent-builder-skill/
│ │ ├── EXAMPLES.md
│ │ └── SKILL.md
│ ├── creating-integration-docs/
│ │ └── SKILL.md
│ └── creating-skills-skill/
│ └── SKILL.md
├── AGENTS.md
└── GEMINI.md
… in tests Consistent with other environment endpoint types (PatchEnvironment etc.) which don't define Querystring and use @ts-expect-error in tests instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: propel-code-bot[bot] <203372662+propel-code-bot[bot]@users.noreply.github.com>
|
|
||
| afterEach(() => { | ||
| (envs as any).NANGO_ADMIN_UUID = originalAdminUUID; | ||
| }); |
There was a problem hiding this comment.
I would create the admin account and slack config in beforeAll so it doesn't need to be done in each test.
| connection_id: connectionId | ||
| connection_id: generateSlackConnectionId(account.uuid, environment.id) | ||
| }); | ||
| if (!connectionConfig || !connectionConfig['incoming_webhook.channel']) { |
There was a problem hiding this comment.
why !connectionConfig['incoming_webhook.channel']
There was a problem hiding this comment.
bc getConnectionConfig can either return an empty object or a null, see this. From my understanding, I could be wrong here since my JS is a bit rusty, when there is no record in the DB we return an empty object, but when there is a record we just return the connection_config column which can be null.
| this.integrationKey, | ||
| adminRes.environment.id | ||
| ); | ||
| if (slackConnectionResult.error?.type === 'unknown_connection') { |
There was a problem hiding this comment.
can we be consistent and use the same fallback condition here and in getEnvironment
There was a problem hiding this comment.
Let me know if Im missing something here, but both are not semantically equivalent. While this one just makes a look up to the db for checking if a connection exists for enabling the dual look up (originally there was an expectation that this function should always return a record and should be attributed to the connection slack one, otherwise this would mean that the dataset was corrupted or there was a bug - which is what is happening Today) the getEnvironment one uses the getConnectionConfig which is kinda different.
We could try to use in both cases connectionService.getConnection, but this is what we already had in place before. Also remember that we will remove this dual look up.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Renaming an environment broke Slack alerts because the connection id was built using the environment name. Switch to environment id (stable) for new installations and add a fallback to the legacy name-based id for existing ones.
Tests run in local:
The update also applies the dual-lookup behavior across server-side Slack channel resolution, notification sending, and webapp disconnect flows, with
connectSlacknow constructing IDs fromenvId, and it expands API typing plus adds integration tests for the current-environment endpoint to validate Slack channel resolution for both new and legacy formats.Possible Issues
• Legacy disconnect retry in
slackDisconnectonly triggers on404; other failure statuses may leave legacy connections undeleted.This summary was automatically generated by @propel-code-bot