Skip to content

fix: resolve interview scheduling and auth redirect by updating schem…#416

Open
bhaikd wants to merge 4 commits into
santanu-atta03:mainfrom
bhaikd:main
Open

fix: resolve interview scheduling and auth redirect by updating schem…#416
bhaikd wants to merge 4 commits into
santanu-atta03:mainfrom
bhaikd:main

Conversation

@bhaikd

@bhaikd bhaikd commented Jul 4, 2026

Copy link
Copy Markdown

Pull Request — Intervyo

Thank you for contributing to **Intervyo, an AI-powered interview simulation platform!
Please fill out the following details to help us review your PR efficiently.


📌 Related Issue

Fixes # (mention issue number here)
Fixes Issue #413

Description of Changes

Describe your changes and their purpose.
Fixed a critical authentication redirect bug that occurred when scheduling and starting an interview. The issue was caused by a combination of payload/schema mismatch during resume uploads, missing backend retrieval endpoints, and incorrect client-side parameter naming.

Specifically:

Frontend Navigation Fix: Updated InterviewSetup.jsx to navigate using the returned interview ID or interviewID instead of the undefined _id property, preventing routing to /interview/undefined.
Database Schema Expansion: Added role, resumeUrl, resumeText, and scheduledAt fields to Interview.model.js and made the direct configuration properties (domain, subDomain, and interviewType) optional.
Backend Controller Enhancement: Updated createInterview in Interview.controller.js to support both the direct-config flow and the resume-upload flow. Added PDF parsing via pdf-parse and file storage via Cloudinary (uploadToCloudinary) and dynamically inferred the required domain details from the specified job role.
Retrieval Endpoints: Implemented and registered GET /api/interviews/:interviewId (getInterviewById) and GET /api/interviews/:interviewId/session (getInterviewSession) on the backend to allow the interview room to load the scheduled interview's metadata.

Type of Change
🐛 Bug Fix

Testing
Describe the tests you ran to verify your changes.
Tested locally (validated controller, model, and route syntax via node --check to ensure no syntax errors or load issues exist).
No tests required
📸 Screenshots / Video
No UI elements were modified. The fix targets data integration, file uploads, and routing logic.

✅ Checklist
I've read the CONTRIBUTING.md guidelines.
My code follows the project’s conventions.
I've linked the related issue correctly.
I've tested my changes locally.
I've added or updated documentation/comments if needed.
My PR title follows the branch & commit naming conventions.
My changes introduce no new warnings or errors.
I've performed a self-review of my work.

…a, controller, routes, and frontend navigation
Copilot AI review requested due to automatic review settings July 4, 2026 23:02
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

@bhaikd is attempting to deploy a commit to the santanu-atta03's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Thanks for creating a PR for your Issue! ☺️

We'll review it as soon as possible.
In the meantime, please double-check the file changes and ensure that all commits are accurate.

If there are any unresolved review comments, feel free to resolve them. 🙌🏼

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses an authentication/redirect loop occurring after interview setup by ensuring the frontend navigates using a valid interview identifier and by adding backend support for retrieving scheduled interview metadata/session data needed to load the interview room.

Changes:

  • Fixed frontend navigation to route using id/interviewId returned from the create-interview API instead of _id.
  • Expanded the Interview schema to support resume-based scheduling metadata (role/resume URL/text/scheduled time) and made some config fields optional.
  • Enhanced backend interview creation to support a resume-upload flow (PDF parsing + Cloudinary upload) and added retrieval endpoints for interview details and session.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
Frontend/src/components/AiInterview/InterviewSetup.jsx Navigates to the interview room using the returned interview identifier.
Backend/routes/interview.route.js Registers new GET endpoints to retrieve interview details and session data.
Backend/models/Interview.model.js Adds scheduling + resume fields and relaxes some config requirements.
Backend/controllers/Interview.controller.js Implements dual create-interview flows (direct config vs resume upload) and adds retrieval handlers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 92 to 95
try {
const interview = await createInterview(data, setLoading, token);
navigate(`/interview/${interview._id}`);
navigate(`/interview/${interview.id || interview.interviewId}`);
} catch (error) {
Comment on lines +797 to +802
if (!finalDomain || !finalSubDomain || !finalInterviewType) {
return res.status(400).json({
success: false,
message: "Please provide all required fields (domain, subDomain, interviewType)",
});
}
Comment thread Backend/controllers/Interview.controller.js Outdated
Comment on lines +765 to +775
try {
const uploadResult = await uploadToCloudinary(resumeFile, "resumes");
resumeUrl = uploadResult.secure_url;
} catch (uploadError) {
console.error("Cloudinary upload error:", uploadError);
return res.status(500).json({
success: false,
message: "Failed to upload resume to Cloudinary",
error: uploadError.message,
});
}
Comment on lines +2081 to +2085
const { interviewId } = req.params;
const userId = req.user.id;

const interview = await Interview.findOne({ _id: interviewId, userId });

Comment on lines +2110 to +2114
const { interviewId } = req.params;
const userId = req.user.id;

const session = await InterviewSession.findOne({ interviewId, userId });

Comment on lines +86 to +90
// Get single interview details
router.get("/:interviewId", interviewController.getInterviewById);

// Get interview session
router.get("/:interviewId/session", interviewController.getInterviewSession);
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