Skip to content

[WEB 4252] chore: updated the favicon request for work item link#7173

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
chore-crawl-work-for-favicon
Jun 6, 2025
Merged

[WEB 4252] chore: updated the favicon request for work item link#7173
sriramveeraghanta merged 2 commits intopreviewfrom
chore-crawl-work-for-favicon

Conversation

@NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Jun 5, 2025

Description

This pull request moves the crawl_work_item_link_title functionality from a direct function call to a background job. It also improves error handling by ensuring that the favicon is still retrieved even if fetching the title from the URL fails.

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling and logging when fetching work item link titles and favicons.
    • Reduced request timeouts for faster responses.
  • Chores

    • Converted work item link title processing to asynchronous background tasks for improved performance.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 5, 2025

Walkthrough

This update modifies how the crawl_work_item_link_title background task is invoked after creating or updating issue links. The task is now enqueued asynchronously in both API endpoints and viewsets. Additionally, the error handling and request timeouts in the background task are refined, and the function is reorganized within its module.

Changes

File(s) Change Summary
apiserver/plane/api/views/issue.py Enqueue crawl_work_item_link_title as a background task after saving an IssueLink in post and patch methods.
apiserver/plane/app/views/issue/link.py Changed crawl_work_item_link_title calls to use .delay() for asynchronous execution in create and partial_update methods.
apiserver/plane/bgtasks/work_item_link_task.py Refined error handling, reduced HTTP request timeouts, reorganized crawl_work_item_link_title function within the file.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API/View
    participant BGTaskQueue
    participant WorkItemTask

    Client->>API/View: Create or update IssueLink
    API/View->>API/View: Save IssueLink
    API/View->>BGTaskQueue: Enqueue crawl_work_item_link_title(id, url)
    BGTaskQueue->>WorkItemTask: Execute crawl_work_item_link_title
    WorkItemTask->>WorkItemTask: Fetch and parse link title (with refined error handling)
Loading

Possibly related PRs

Suggested labels

🌟improvement, ready to merge

Suggested reviewers

  • sriramveeraghanta
  • dheeru0198

Poem

A rabbit hops through lines of code,
Where links are fetched and tasks bestowed.
With timeouts trimmed and errors caught,
Async calls—no waiting fraught!
In background queues the titles grow,
As bunnies cheer, the tasks now flow.
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf83da0 and 49c0751.

📒 Files selected for processing (1)
  • apiserver/plane/bgtasks/work_item_link_task.py (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apiserver/plane/bgtasks/work_item_link_task.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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: 0

🧹 Nitpick comments (3)
apiserver/plane/bgtasks/work_item_link_task.py (1)

53-53: Consider if 1-second timeout is too aggressive.

Reducing the timeout from 2 seconds to 1 second might cause more failures for legitimate but slower websites. This could result in more link previews missing both titles and favicons.

Consider testing with a range of websites to validate that 1 second is sufficient, or implement a tiered timeout approach:

-response = requests.get(url, headers=headers, timeout=1)
+response = requests.get(url, headers=headers, timeout=2)
-response = requests.get(favicon_url, headers=headers, timeout=1)
+response = requests.get(favicon_url, headers=headers, timeout=2)

Also applies to: 146-146

apiserver/plane/app/views/issue/link.py (1)

48-50: Good async conversion, but consider adding error handling.

Converting to background tasks improves response times by moving HTTP operations out of the request-response cycle. However, consider adding error handling for task enqueuing failures.

Consider wrapping the task calls in try-except blocks:

-crawl_work_item_link_title.delay(
-    serializer.data.get("id"), serializer.data.get("url")
-)
+try:
+    crawl_work_item_link_title.delay(
+        serializer.data.get("id"), serializer.data.get("url")
+    )
+except Exception as e:
+    logger.warning(f"Failed to enqueue link title crawling task: {e}")

Also applies to: 81-83

apiserver/plane/api/views/issue.py (1)

695-697: Async task integration implemented correctly.

The background task calls are properly placed after serializer.save() in both create and update operations, ensuring the IssueLink object exists before the task processes it.

Consider adding error handling for task enqueuing failures (same pattern as suggested for the app views):

-crawl_work_item_link_title.delay(
-    serializer.data.get("id"), serializer.data.get("url")
-)
+try:
+    crawl_work_item_link_title.delay(
+        serializer.data.get("id"), serializer.data.get("url")
+    )
+except Exception as e:
+    logger.warning(f"Failed to enqueue link title crawling task: {e}")

Also applies to: 725-727

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f37f1e and cf83da0.

📒 Files selected for processing (3)
  • apiserver/plane/api/views/issue.py (3 hunks)
  • apiserver/plane/app/views/issue/link.py (2 hunks)
  • apiserver/plane/bgtasks/work_item_link_task.py (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apiserver/plane/app/views/issue/link.py (2)
apiserver/plane/bgtasks/work_item_link_task.py (1)
  • crawl_work_item_link_title (169-175)
web/core/local-db/utils/utils.ts (1)
  • delay (155-155)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apiserver/plane/bgtasks/work_item_link_task.py (2)

49-61: Excellent error handling improvement.

The nested try-except block ensures that favicon retrieval continues even if the title fetch fails, which aligns perfectly with the PR objective of maintaining favicon display despite title retrieval issues.


168-175: Function relocation looks good.

Moving the crawl_work_item_link_title function to the end of the file with the @shared_task decorator is appropriate for better code organization.

apiserver/plane/api/views/issue.py (1)

61-61: Import addition looks correct.

The import of crawl_work_item_link_title from the background task module is properly placed and necessary for the async task integration.

@NarayanBavisetti NarayanBavisetti changed the title [WEB 4252] chore: added the favicon to link [WEB 4252] chore: updated the favicon request for work item link Jun 5, 2025
@sriramveeraghanta sriramveeraghanta merged commit 053c895 into preview Jun 6, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-crawl-work-for-favicon branch June 6, 2025 09:32
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* chore: added the favicon to link

* chore: added none validation for soup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants