Skip to content

fix(slack): use environment id for slack connection id with legacy fallback#5559

Open
pfreixes wants to merge 9 commits intomasterfrom
pfreixes/nan-3540-slack-alert-dual-lookup
Open

fix(slack): use environment id for slack connection id with legacy fallback#5559
pfreixes wants to merge 9 commits intomasterfrom
pfreixes/nan-3540-slack-alert-dual-lookup

Conversation

@pfreixes
Copy link

@pfreixes pfreixes commented Mar 4, 2026

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:

  • Test that new slack alerts are resilient to an environment name change
  • Test that legacy slack alerts are still working when they did not suffer an environment name change
  • Test that once legacy slack alerts once renamed they work

The update also applies the dual-lookup behavior across server-side Slack channel resolution, notification sending, and webapp disconnect flows, with connectSlack now constructing IDs from envId, 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 slackDisconnect only triggers on 404; other failure statuses may leave legacy connections undeleted.


This summary was automatically generated by @propel-code-bot

…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>
@linear
Copy link

linear bot commented Mar 4, 2026

propel-code-bot[bot]

This comment was marked as outdated.

…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>
@pfreixes pfreixes requested a review from a team March 4, 2026 15:31
Copy link
Collaborator

@TBonnin TBonnin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't !slackConnectionResult.success redundant?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@pfreixes pfreixes requested review from TBonnin and rossmcewan March 5, 2026 09:24
@pfreixes
Copy link
Author

pfreixes commented Mar 5, 2026

@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!

pfreixes and others added 2 commits March 5, 2026 10:29
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
propel-code-bot[bot]

This comment was marked as outdated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

@propel-code-bot propel-code-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

pfreixes and others added 2 commits March 5, 2026 10:45
… 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;
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create the admin account and slack config in beforeAll so it doesn't need to be done in each test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point done here.

connection_id: connectionId
connection_id: generateSlackConnectionId(account.uuid, environment.id)
});
if (!connectionConfig || !connectionConfig['incoming_webhook.channel']) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why !connectionConfig['incoming_webhook.channel']

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this was the original pattern, see this

this.integrationKey,
adminRes.environment.id
);
if (slackConnectionResult.error?.type === 'unknown_connection') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we be consistent and use the same fallback condition here and in getEnvironment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@TBonnin TBonnin self-requested a review March 6, 2026 02:43
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants