Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira - Add Override existing webhooks optional prop to all sources #14471

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Oct 30, 2024

Resolves #14440

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced an option to override existing webhooks when creating new ones.
    • Added a method to delete existing webhooks based on user preference.
  • Updates

    • Updated version of the Jira package to 0.1.3.
    • Incremented version numbers for various event sources to 0.0.10.
    • Renamed event designations for clarity (e.g., "New Issue Created Event" to "New Issue Created Event (Instant)").

Copy link

vercel bot commented Oct 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Oct 30, 2024 6:21pm
pipedream-docs ⬜️ Ignored (Inspect) Oct 30, 2024 6:21pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Oct 30, 2024 6:21pm

Copy link
Contributor

coderabbitai bot commented Oct 30, 2024

Walkthrough

This pull request introduces several changes to the Jira integration components. The package version of @pipedream/jira is updated from 0.1.2 to 0.1.3. Additionally, a new optional property overrideExistingWebhooks is added to the webhook management functionality, allowing users to delete existing webhooks if desired. Several event-related components also see their version numbers incremented to 0.0.10, and the names of some events are updated to include "(Instant)" for clarity.

Changes

File Change Summary
components/jira/package.json Updated version from 0.1.2 to 0.1.3.
components/jira/sources/common/common.mjs Added optional property overrideExistingWebhooks (default: false) and method deleteExistingWebhooks(). Modified activate hook to check overrideExistingWebhooks.
components/jira/sources/events/events.mjs Updated version from 0.0.9 to 0.0.10.
components/jira/sources/issue-created/issue-created.mjs Updated name from "New Issue Created Event" to "New Issue Created Event (Instant)" and version from 0.0.9 to 0.0.10.
components/jira/sources/issue-deleted/issue-deleted.mjs Updated name from "New Issue Deleted Event" to "New Issue Deleted Event (Instant)" and version from 0.0.9 to 0.0.10.
components/jira/sources/issue-updated/issue-updated.mjs Updated name from "New Issue Updated Event" to "New Issue Updated Event (Instant)" and version from 0.0.9 to 0.0.10.

Assessment against linked issues

Objective Addressed Explanation
Add Override existing webhooks optional prop to all sources (14440)

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • GTFalcao
  • jcortes

Poem

In the land of Jira, we hop and play,
New webhooks dance, come what may.
With options to override, oh what a treat,
Our integration's now truly neat!
Version updates, we cheer with glee,
Hopping along, as happy as can be! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
components/jira/sources/issue-deleted/issue-deleted.mjs (1)

6-6: Verify the description's accuracy regarding webhook limitations.

The description correctly mentions Jira's single webhook limitation, which aligns with the PR objectives. However, it might be helpful to mention the new overrideExistingWebhooks option in the description.

Consider updating the description to include information about the override option:

- "Emit new event when an issue is deleted. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events."
+ "Emit new event when an issue is deleted. Note that Jira supports only one webhook. You can use the `Override existing webhooks` option to replace an existing webhook, or use the `New Event` source to select multiple events."
components/jira/sources/issue-updated/issue-updated.mjs (1)

6-7: Update description to reflect new override capability.

The description mentions Jira's single webhook limitation but should be updated to inform users about the new override functionality.

-  description: "Emit new event when an issue is updated. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.",
+  description: "Emit new event when an issue is updated. Note that Jira supports only one webhook. You can enable 'Override existing webhooks' to replace any existing webhooks, or use the `New Event` source to select multiple events.",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0b30eb9 and 8e5f8cf.

📒 Files selected for processing (6)
  • components/jira/package.json (1 hunks)
  • components/jira/sources/common/common.mjs (2 hunks)
  • components/jira/sources/events/events.mjs (1 hunks)
  • components/jira/sources/issue-created/issue-created.mjs (1 hunks)
  • components/jira/sources/issue-deleted/issue-deleted.mjs (1 hunks)
  • components/jira/sources/issue-updated/issue-updated.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • components/jira/package.json
  • components/jira/sources/events/events.mjs
🔇 Additional comments (7)
components/jira/sources/issue-created/issue-created.mjs (2)

5-5: LGTM! Version bump and name clarification look good.

The changes improve clarity by adding "(Instant)" to the event name and properly increment the version number.

Also applies to: 7-7


Line range hint 11-11: Verify the implementation of Override existing webhooks property.

The PR objective requires adding an Override existing webhooks property to all sources. Since this file spreads the common configuration, we should verify that this property is properly implemented in the common module.

✅ Verification successful

Override existing webhooks property is properly implemented

The property is correctly implemented in the common module (components/jira/sources/common/common.mjs) with:

  • A boolean prop definition with appropriate label, description and default value
  • Integration in the webhook management logic:
    • Checks and deletes existing webhooks during activation if enabled
    • Proper cleanup during deactivation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of overrideExistingWebhooks property in common configuration

# Test 1: Check if the property is defined in common configuration
echo "Checking common.mjs for overrideExistingWebhooks property:"
rg -A 5 "overrideExistingWebhooks" "components/jira/common/common.mjs"

# Test 2: Check if the property is being used in webhook management
echo "Checking webhook-related code:"
rg -A 5 "webhook" "components/jira/common/common.mjs"

Length of output: 466


Script:

#!/bin/bash
# Let's first find the common configuration file location
echo "Finding common configuration file:"
fd -e mjs -e js common components/jira

# Check for webhook-related code in Jira component
echo -e "\nChecking webhook-related code in Jira component:"
rg -l "webhook" components/jira/

# Check for overrideExistingWebhooks in Jira component
echo -e "\nChecking overrideExistingWebhooks in Jira component:"
rg -l "overrideExistingWebhooks" components/jira/

Length of output: 801


Script:

#!/bin/bash
# Let's check the implementation details of overrideExistingWebhooks in common.mjs
echo "Checking overrideExistingWebhooks implementation in common.mjs:"
rg -A 10 "overrideExistingWebhooks" "components/jira/sources/common/common.mjs"

# Let's also check how webhooks are managed in common.mjs
echo -e "\nChecking webhook management in common.mjs:"
rg -B 5 -A 10 "webhook" "components/jira/sources/common/common.mjs"

Length of output: 3617

components/jira/sources/issue-deleted/issue-deleted.mjs (2)

5-5: LGTM! Version bump and name clarification look good.

The changes to include "(Instant)" in the name and bump the version are consistent with other components.

Also applies to: 7-7


Line range hint 11-11: Verify implementation of overrideExistingWebhooks property.

The file extends common functionality via ...common. Let's verify that the overrideExistingWebhooks property is properly implemented in the common file.

✅ Verification successful

Property overrideExistingWebhooks is properly implemented in common.mjs

The verification confirms that overrideExistingWebhooks is correctly implemented in the common file with:

  • Proper property definition with boolean type, label, and description
  • Default value set to false and marked as optional
  • Functional implementation that deletes existing webhooks when enabled
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of overrideExistingWebhooks in common.mjs

# Test 1: Check if common.mjs exists and contains the property definition
echo "Checking for overrideExistingWebhooks property in common.mjs:"
rg -A 10 "overrideExistingWebhooks" "components/jira/sources/common/common.mjs"

# Test 2: Verify the property type and default value
echo -e "\nVerifying property configuration:"
ast-grep --pattern 'props: {
  $$$
  overrideExistingWebhooks: {
    type: "boolean",
    label: "Override existing webhooks",
    description: $$$,
    optional: true,
    default: false,
  },
  $$$
}'

Length of output: 1329

components/jira/sources/issue-updated/issue-updated.mjs (1)

Line range hint 11-11: Verify implementation of override property in common configuration.

The file spreads common configuration which should include the new overrideExistingWebhooks property. Let's verify its implementation.

✅ Verification successful

overrideExistingWebhooks property is properly implemented in common configuration

The property is correctly implemented in components/jira/sources/common/common.mjs with proper type definition, description, and default value. The issue-updated source spreads the common configuration correctly using ...common and its methods via ...common.methods, which includes the webhook override functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of overrideExistingWebhooks property in common configuration

# Test 1: Check if the common configuration file exists and contains the new property
echo "Checking common configuration implementation..."
rg -l "overrideExistingWebhooks" "components/jira/common/common.mjs"

# Test 2: Examine the property definition
echo "Examining property definition..."
rg -A 5 "overrideExistingWebhooks" "components/jira/common/common.mjs"

Length of output: 463


Script:

#!/bin/bash
# Let's first find the common configuration file as it might be in a different location
echo "Looking for common configuration files in Jira component..."
fd "common" components/jira/

# Once we find the file, let's check its content
echo "Looking for files containing overrideExistingWebhooks..."
rg -l "overrideExistingWebhooks" components/jira/

# Let's also check the source file to understand how common config is imported
echo "Checking how common config is imported in issue-updated..."
rg -A 3 "import.*common" "components/jira/sources/issue-updated/issue-updated.mjs"

Length of output: 802


Script:

#!/bin/bash
# Let's examine the implementation of overrideExistingWebhooks in the correct file
echo "Examining overrideExistingWebhooks implementation..."
rg -A 5 "overrideExistingWebhooks" "components/jira/sources/common/common.mjs"

# Let's also check how the common config is used in issue-updated
echo "Checking common config usage in issue-updated..."
rg -A 10 "export default" "components/jira/sources/issue-updated/issue-updated.mjs"

Length of output: 1382

components/jira/sources/common/common.mjs (2)

24-30: LGTM! Well-defined property with clear documentation.

The property definition is well-structured with appropriate type, default value, and a comprehensive description that clearly explains its purpose and when to use it.


Line range hint 24-122: Verify webhook override functionality in staging environment.

The implementation aligns well with the PR objectives, providing users with the ability to override existing webhooks. However, given the critical nature of webhook management, thorough testing is recommended.

✅ Verification successful

Webhook override implementation is properly structured and safe

The implementation shows proper error handling and a safe approach to webhook management:

  • Webhook deletion is properly scoped within deleteExistingWebhooks()
  • The code uses proper async/await patterns for webhook operations
  • Webhook operations are properly integrated with Jira's API endpoints
  • The feature is optional and defaults to false, preventing accidental deletions
  • Proper error propagation through _makeRequest abstraction

The implementation is safe to proceed with as it:

  1. Properly validates webhook existence before deletion
  2. Handles webhook lifecycle (creation/deletion) consistently
  3. Maintains proper state management through _getHookID and _setHookID
  4. Implements proper cleanup in the deactivate hook
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of webhook override functionality
# Look for any potential issues in error handling or edge cases

# Test 1: Check for proper error handling in webhook-related code
echo "Checking error handling patterns..."
rg -l 'catch|throw|error' components/jira/

# Test 2: Verify consistent property naming
echo "Verifying consistent property naming..."
rg -l 'overrideExistingWebhooks?' components/jira/

# Test 3: Check for potential race conditions in webhook management
echo "Checking for concurrent webhook operations..."
rg -l 'createHook|deleteHook' components/jira/

Length of output: 1227


Script:

#!/bin/bash
# Let's examine the error handling and webhook management implementation more closely

# Check error handling in webhook deletion
echo "Examining webhook deletion error handling:"
rg -A 5 -B 5 'deleteHook' components/jira/sources/common/common.mjs components/jira/jira.app.mjs

# Check webhook creation and related error handling
echo "Examining webhook creation implementation:"
rg -A 5 -B 5 'createHook' components/jira/jira.app.mjs

# Look for any existing webhook validation
echo "Checking webhook validation:"
rg -A 5 -B 5 'getWebhook' components/jira/jira.app.mjs

Length of output: 3024

components/jira/sources/common/common.mjs Show resolved Hide resolved
components/jira/sources/common/common.mjs Show resolved Hide resolved
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927 lgtm! Ready for QA!

@michelle0927 michelle0927 merged commit 8fe7317 into master Oct 31, 2024
12 checks passed
@michelle0927 michelle0927 deleted the issue-14440 branch October 31, 2024 14:40
lcaresia pushed a commit that referenced this pull request Dec 3, 2024
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.

[FEATURE] Jira - Add Override existing webhooks optional prop to all sources
2 participants