Skip to content

Commit

Permalink
Merge pull request #4837 from activepieces/fix/connection
Browse files Browse the repository at this point in the history
fix(connections): fail if the connection is not found
  • Loading branch information
abuaboud committed May 31, 2024
2 parents 5f98d0b + e99453f commit 5eea910
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/community/connections/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-connections",
"version": "0.3.4"
"version": "0.4.0"
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Property, createAction } from '@activepieces/pieces-framework';
import { isNil } from 'lodash';

const markdown = `
**Advanced Piece**
<br>
Use this action to get connections dynamically by their names from this project.
<br>
Only use this piece if you're unsure which connection to use beforehand, like when the link name is sent through a webhook message.
Use this piece If you are unsure which connection to use beforehand, such as when the connection name is sent through a webhook message.
**Notes:**
- Use this action to retrieve connection values by their names from this project.
- After testing the step, you can use the dynamic value in the piece by clicking (X) and referring to this step.
`;

export const readConnection = createAction({
Expand All @@ -23,6 +26,13 @@ export const readConnection = createAction({
}),
},
async run(ctx) {
return await ctx.connections.get(ctx.propsValue.connection_name);
const connection = await ctx.connections.get(ctx.propsValue.connection_name);
if (isNil(connection)) {
throw new Error(JSON.stringify({
message: 'Connection not found',
connectionName: ctx.propsValue.connection_name,
}));
}
return connection;
},
});
12 changes: 0 additions & 12 deletions packages/pieces/community/connections/src/lib/connections.mdx

This file was deleted.

0 comments on commit 5eea910

Please sign in to comment.