Skip to content

Conversation

@pablohashescobar
Copy link
Member

@pablohashescobar pablohashescobar commented Mar 7, 2025

Description

fix: assignee validation when updating issues
Fixes #6718

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Test Scenarios

  • create issue with assignees
  • add/remove assignees
  • remove all assignees
  • update other attributes and check if assignee persists
  • validate activity logs
  • check all the above cases in intake issues and draft issues as well

Summary by CodeRabbit

  • New Features

    • Enhanced issue update handling by providing additional project context for more accurate processing.
  • Refactor

    • Streamlined the internal logic for creating and updating issues by simplifying assignee handling.
    • Updated naming conventions to improve clarity.
  • Style

    • Refined formatting in error responses and overall code presentation for improved readability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

Walkthrough

This pull request modifies the serialization and view handling for issue objects. In the serializer, the parameter name in the validate method is renamed from data to attrs, and the handling of assignees in the create and update methods is simplified by removing the separate filtering function. In addition, multiple view files have been updated to add a context parameter (providing a project_id) during the partial update of issues, along with minor formatting improvements and an import cleanup.

Changes

Files Change Summary
apiserver/plane/app/serializers/issue.py In IssueCreateSerializer, renamed parameter from data to attrs in validate; simplified assignee filtering in create and update methods by directly using the assignees variable.
apiserver/plane/app/views/intake/base.py
apiserver/plane/app/views/issue/base.py
apiserver/plane/space/views/intake.py
In views, added context={"project_id": ...} to the IssueCreateSerializer instantiation in the partial_update methods; reformatted the error response in list and adjusted minor formatting; removed unused import (State) in the intake view.

Sequence Diagram(s)

sequenceDiagram
    participant Client as API Client
    participant View as View (IntakeIssueViewSet/IssueViewSet/IntakeIssuePublicViewSet)
    participant Serializer as IssueCreateSerializer

    Client->>View: HTTP PATCH /issue/...
    View->>Serializer: Instantiate with data, partial flag, and context {"project_id": ...}
    Serializer-->>View: Validate and process issue update
    View-->>Client: Return HTTP Response
Loading

Possibly related PRs

Suggested labels

🐛bug, ⚙️backend

Suggested reviewers

  • sriramveeraghanta

Poem

Oh, swift coder, hop with glee,
I'm a rabbit dancing merrily.
Changes in context and names so neat,
Assignees streamlined in every beat.
From code fields to views we bound—
In every line, a joy is found!
🐇💻


📜 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 7005ae2 and 32eea2f.

📒 Files selected for processing (4)
  • apiserver/plane/app/serializers/issue.py (3 hunks)
  • apiserver/plane/app/views/intake/base.py (2 hunks)
  • apiserver/plane/app/views/issue/base.py (4 hunks)
  • apiserver/plane/space/views/intake.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (16)
apiserver/plane/space/views/intake.py (2)

15-15: Import cleanup: Removed unused State model import.

The State model has been correctly removed from the imports as it's not used in this file.


205-210: Adding project context to serializer for proper assignee validation.

The serializer now receives the project_id in its context, which is essential for properly validating assignees during issue updates.

apiserver/plane/app/views/issue/base.py (4)

638-640: Adding project context to serializer for proper assignee validation.

The serializer now receives the project_id in its context, which is essential for properly validating assignees during issue updates.


1120-1120: Improved readability of integer validation check.

The condition for validating if a string represents an integer has been reformatted for better readability while maintaining the same logic.


1136-1136: Using case-insensitive project identifier comparison.

Using identifier__iexact ensures case-insensitive matching when retrieving projects by identifier.


1238-1240: Improved formatting of filter parameters.

The filter parameters for IssueSubscriber have been formatted more consistently.

apiserver/plane/app/views/intake/base.py (2)

181-183: Improved error response formatting.

The error response for a missing intake has been reformatted for better readability while maintaining the same functionality.


390-390: Adding project context to serializer for proper assignee validation.

The serializer now receives the project_id in its context, which is essential for properly validating assignees during issue updates.

apiserver/plane/app/serializers/issue.py (8)

114-114: Improved naming convention from 'data' to 'attrs'.

The parameter name change from data to attrs follows better Django REST Framework conventions for validate methods.


116-118: Improved formatting of date validation logic.

The condition for validating start and target dates has been reformatted for better readability while maintaining the same logic.


122-128: Simplified assignee validation using context-based filtering.

The assignee validation now directly filters valid assignees using the project_id from the context, replacing the previous approach. This ensures that only valid project members with appropriate roles can be assigned to issues.


147-147: Simplified condition for checking assignees.

The condition to check if assignees exist has been simplified while maintaining the same logic.


152-159: Simplified assignee creation in bulk create operation.

The creation of IssueAssignee instances has been simplified to directly use the assignee IDs from the filtered list.


167-175: Improved formatting of default assignee check.

The condition for checking if the default assignee should be used has been reformatted for better readability.


219-219: Simplified assignee existence check in update method.

The condition to check if assignees exist in the update method has been simplified.


225-232: Simplified assignee creation in update method's bulk create operation.

Similar to the create method, the update method has been simplified to directly use the assignee IDs from the filtered list.

✨ 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.
    • 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 generate docstrings to generate docstrings for 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.

@sriramveeraghanta sriramveeraghanta merged commit 40c0bbc into preview Mar 7, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-assignee-validation branch March 7, 2025 07:38
@sriramveeraghanta sriramveeraghanta added this to the v0.25.2 milestone Mar 9, 2025
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* fix: assignee validation

* chore: remove prints

* fix: remove all assignees
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.

[bug]: Changing the state is removing assignee

3 participants