Skip to content

Conversation

jairo-litman
Copy link
Contributor

@jairo-litman jairo-litman commented Aug 5, 2025

This pull request addresses an issue where pull request user data (authors, reviewers, assignees) was not being saved correctly.

The core change involves modifying the data structures and method signatures across the application to consistently pass an OrganizationAndTeamData object, which now includes an optional teamId alongside the organizationId.

Key changes include:

  • Propagation of teamId: The teamId is now extracted from the request body in the UpdatePullRequestToNewFormatUseCase and passed down through the PullRequestsService and its helper methods.
  • Enhanced User Data Extraction: Methods responsible for extracting and saving pull request user data (extractUser, extractUsers) now receive the OrganizationAndTeamData object. This ensures that user lookups (e.g., via the underlying code management client like Octokit) are performed with the correct team context, facilitating the accurate saving of user information.
  • API Update: The /update-pull-requests endpoint's DTO (updatePullRequestDto) has been updated to accept an optional teamId parameter.

This comment has been minimized.

[],
[],
platformType,
organizationAndTeamData?.[0],
Copy link

Choose a reason for hiding this comment

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

kody code-review Refactoring low

organizationAndTeamData[0],

The optional chaining on organizationAndTeamData?.[0] is unnecessary. The guard clause on line 78 (if (!configs || !configs.length)) ensures that the configs array is non-empty at this point in the code. Consequently, organizationAndTeamData will also be a non-empty array, meaning organizationAndTeamData[0] will always be defined. Removing the optional chaining (?.) would make the code cleaner and more accurately reflect the established logic that this value cannot be undefined.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Comment on lines 291 to 292
const organizationId =
organizationAndTeamData?.organizationId ?? '';
Copy link

Choose a reason for hiding this comment

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

kody code-review Potential Issues critical

const organizationId = organizationAndTeamData?.organizationId;
if (!organizationId) {
    this.logger.error({
        message: `organizationId is missing in organizationAndTeamData for PR #${pullRequest?.number}`,
        context: PullRequestsService.name,
        metadata: {
            pullRequestNumber: pullRequest?.number,
            repositoryName: repository?.name,
            organizationAndTeamData,
        },
    });
    return null;
}

The current implementation defaults organizationId to an empty string if organizationAndTeamData or its organizationId property is missing. This can lead to creating pull request records with an invalid organizationId, causing data integrity issues. It's better to fail early by adding a guard clause to validate that organizationId is present and logging an error if it's missing. The error log has been enhanced to include organizationAndTeamData in the metadata for better traceability, adhering to company logging standards.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Copy link

@kodus-ai kodus-ai bot left a comment

Choose a reason for hiding this comment

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

Copy link

kodus-ai bot commented Aug 5, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@Wellington01 Wellington01 merged commit 0d55857 into main Aug 5, 2025
1 check failed
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.

2 participants