Skip to content

Conversation

tejaskh3
Copy link
Contributor

@tejaskh3 tejaskh3 commented Jun 19, 2025

Date:

Developer Name:


Issue Ticket Number

Description

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1

Test Coverage

Screenshot 1

Additional Notes

Description by Korbit AI

What change is being made?

Update and fix the API for handling Out-Of-Office (OOO) requests, including changes in handling data structures and logging.

Why are these changes being made?

These changes address issues with the existing OOO request handling by improving the mapping of response data to align with expected formats, updating the logging for better traceability, and correcting function parameters and data attributes to align with expected API behavior. Additionally, deprecated or non-functional code related to email retrieval from GitHub has been commented out for potential refactoring or removal in the future.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

@tejaskh3 tejaskh3 self-assigned this Jun 19, 2025
Copy link

coderabbitai bot commented Jun 19, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility for out-of-office (OOO) requests, ensuring data is displayed in the expected format on the dashboard.
  • New Features
    • Added support for new request fields, including "comment" and updated "status" options when updating requests.
  • Style
    • Enhanced logging throughout request and status update processes to improve traceability and debugging.
  • Chores
    • Updated internal validation and data handling for requests and OOO status updates.

Walkthrough

This update introduces additional logging across several controllers and models, refines data handling for out-of-office (OOO) requests by updating field names and response mapping, modifies validation schemas, and adds a utility function for OOO data transformation. Some fallback logic for GitHub authentication is commented out, and compatibility adjustments are made for legacy data formats.

Changes

File(s) Change Summary
controllers/auth.js Commented out fallback logic for fetching user email from GitHub API if missing in user data.
controllers/oooRequests.ts Added logging, updated field handling from message/requestedBy to reason/userId, filtered requests by type, refined data.
controllers/requests.ts Added a console log upon entering the main update request controller.
middlewares/validators/requests.ts Replaced "message" with "comment" and "status" fields in validation, added log before calling next().
models/requests.ts Changed property checks from state to status, added OOO data mapping for legacy compatibility, updated imports.
models/userFutureStatus.ts, models/userStatus.js Added console logs to trace function entry and Firestore updates in user status functions.
utils/mapOOOResponseData.ts Introduced new utility function to map OOO response data from new to old format for compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller
    participant Model
    participant Utils

    Client->>Controller: Update OOO Request
    Controller->>Model: getRequests({ type: 'OOO', ... })
    Model->>Model: Fetch OOO requests from DB
    Model->>Utils: mapOOOResponseData(requests)
    Utils-->>Model: Mapped legacy format data
    Model-->>Controller: Return mapped data
    Controller-->>Client: Respond with data
Loading

Possibly related PRs

  • Real-Dev-Squad/website-backend#2386: Adds test cases reflecting changes in OOO request data structure and validation, directly related to the data mapping and field renaming in this PR.
  • Real-Dev-Squad/website-backend#2383: Modifies OOO request creation and authorization logic, sharing code-level changes in controllers/oooRequests.ts and related field updates.

Suggested labels

bug, bug-fix, backend, tests

Suggested reviewers

  • prakashchoudhary07
  • MayankBansal12
  • AnujChhikara

Poem

A rabbit hopped with joyful cheer,
As logs and fields became more clear.
OOO requests now mapped just right,
With "reason" shining in the light.
Console logs to guide the way,
Legacy and new, both here to stay!
🐇✨


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.

@tejaskh3 tejaskh3 marked this pull request as draft June 19, 2025 05:28
@coderabbitai coderabbitai bot added backend bug Something isn't working bug-fix Fixing a bug tests labels Jun 19, 2025
Copy link

@korbit-ai korbit-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.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Security Missing Email Verification in GitHub Auth ▹ view ✅ Fix detected
Functionality Missing GitHub Email Fallback ▹ view ✅ Fix detected
Design Data Transform Logic Violates SRP and OCP ▹ view
Files scanned
File Path Reviewed
utils/mapOOOResponseData.ts
models/userFutureStatus.ts
controllers/requests.ts
middlewares/validators/requests.ts
models/requests.ts
controllers/oooRequests.ts
controllers/auth.js
models/userStatus.js

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Copy link

@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: 9

🔭 Outside diff range comments (1)
middlewares/validators/requests.ts (1)

61-71: Clarify schema design with both 'state' and 'status' fields.

The schema now includes both state (required) and status (optional) fields with the same validation rules. This could lead to confusion about which field should be used by API consumers. Consider:

  1. Adding clear documentation about when to use each field
  2. Planning a migration path to consolidate to a single field
  3. Adding validation to ensure both fields don't conflict when provided

Consider adding a custom validation to prevent conflicting values:

  schema = schema.custom((value, helpers) => {
    if (value.state && value.status && value.state !== value.status) {
      return helpers.error('custom.conflictingFields');
    }
    return value;
  }).messages({
    'custom.conflictingFields': 'state and status fields cannot have different values'
  });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d16d08 and 156f9c8.

📒 Files selected for processing (8)
  • controllers/auth.js (1 hunks)
  • controllers/oooRequests.ts (3 hunks)
  • controllers/requests.ts (1 hunks)
  • middlewares/validators/requests.ts (1 hunks)
  • models/requests.ts (3 hunks)
  • models/userFutureStatus.ts (1 hunks)
  • models/userStatus.js (2 hunks)
  • utils/mapOOOResponseData.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build (22.10.0)
🔇 Additional comments (6)
controllers/auth.js (1)

175-188: Let’s locate the auth controller and verify whether that fallback block still exists under a different path:

#!/bin/bash
# 1. Find any file named auth.js
echo "=== Finding auth.js ==="
find . -type f -name auth.js

# 2. If found, dump lines where GitHub email fallback would live (around line 175)
echo
echo "=== Searching for GitHub email fallback references ==="
grep -R "githubApi.baseUrl" -n .

echo
grep -R "/user/emails" -n .
controllers/oooRequests.ts (2)

123-123: Good addition of type filter for specificity.

Adding the type filter REQUEST_TYPE.OOO makes the query more specific and prevents potential data inconsistencies.


126-126: ```shell
#!/bin/bash

Locate and inspect the destructuring in controllers/oooRequests.ts

echo "Finding requestData usage in controllers/oooRequests.ts..."
rg -n "requestData" controllers/oooRequests.ts

Show context around the destructuring (20 lines before and after)

LINE=$(rg -n "const { from, until, userId, reason }" controllers/oooRequests.ts | cut -d: -f1)
sed -n "$((LINE-10)),$((LINE+10))p" controllers/oooRequests.ts


</details>
<details>
<summary>models/requests.ts (3)</summary>

`3-3`: **Approve new imports.**

The addition of `REQUEST_TYPE` constant, `mapOOOResponseData` utility, and logger are appropriate for the new functionality.



Also applies to: 11-12

---

`154-157`: **Good backward compatibility handling.**

The conditional transformation using `mapOOOResponseData` when `dev` flag is false provides good backward compatibility for the dashboard site expecting the old data format.


The comment clearly explains the reasoning, and the implementation properly handles the data format transformation based on the request type and dev flag.

---

`42-42`: ```shell
#!/bin/bash
# Locate controllers/oooRequests.ts and print around createRequest usage
FILE=$(fd -e ts "controllers/oooRequests.ts" | head -1)
if [ -n "$FILE" ]; then
  grep -R -n "createRequest" -n "$FILE" | head -5
  echo "------- Context --------"
  sed -n '1,200p' "$FILE"
else
  echo "controllers/oooRequests.ts not found"
fi

@tejaskh3 tejaskh3 added the hacktoberfest hacktoberfest celebration to contribution to open source label Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working bug-fix Fixing a bug hacktoberfest hacktoberfest celebration to contribution to open source tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant