From fb1429c2aedbb907f7589eda455458481e448ba7 Mon Sep 17 00:00:00 2001 From: Nishitha Reddy Date: Wed, 20 May 2026 09:25:56 +0530 Subject: [PATCH 1/5] Fix interview response validation for expired interviews --- backend/app/schemas/interview.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/app/schemas/interview.py b/backend/app/schemas/interview.py index 1c5c9bb..0898f3f 100644 --- a/backend/app/schemas/interview.py +++ b/backend/app/schemas/interview.py @@ -15,7 +15,8 @@ class DsaTopicCreate(BaseModel): difficulty: str -class CustomInterviewCreate(BaseModel): +# Shared fields (NO validation here) +class CustomInterviewBase(BaseModel): description: str position: str experience: str @@ -31,6 +32,10 @@ class CustomInterviewCreate(BaseModel): questions: list[CustomQuestionCreate] = [] dsa_topics: list[DsaTopicCreate] = [] + +# Create schema → validation stays here +class CustomInterviewCreate(CustomInterviewBase): + @model_validator(mode="after") def validate_times_and_scores(self) -> "CustomInterviewCreate": tz = self.start_time.tzinfo @@ -38,8 +43,10 @@ def validate_times_and_scores(self) -> "CustomInterviewCreate": if self.start_time <= now: raise BadRequestError("start_time must be in the future") + if self.end_time <= now: raise BadRequestError("end_time must be in the future") + if self.submission_deadline <= now: raise BadRequestError("submission_deadline must be in the future") @@ -49,8 +56,11 @@ def validate_times_and_scores(self) -> "CustomInterviewCreate": if self.dsa_score is not None or self.dev_score is not None: dsa = self.dsa_score or 0 dev = self.dev_score or 0 + if dsa + dev != 100: - raise BadRequestError("The sum of dsa_score and dev_score must be exactly 100") + raise BadRequestError( + "The sum of dsa_score and dev_score must be exactly 100" + ) return self @@ -71,11 +81,12 @@ class Config: from_attributes = True -class CustomInterviewResponse(CustomInterviewCreate): +# Response schema → NO create validation +class CustomInterviewResponse(CustomInterviewBase): id: int org_id: int - questions: list[CustomQuestionResponse] = [] # type: ignore[assignment] - dsa_topics: list[DsaTopicResponse] = [] # type: ignore[assignment] + questions: list[CustomQuestionResponse] = [] + dsa_topics: list[DsaTopicResponse] = [] class Config: from_attributes = True @@ -96,4 +107,4 @@ class Config: class AppliedInterviewResponse(CustomInterviewBasicResponse): - status: str + status: str \ No newline at end of file From 3cf8bac05e4e726c137f55d614f9fca1f4d53458 Mon Sep 17 00:00:00 2001 From: Nishitha Reddy Date: Wed, 20 May 2026 09:31:50 +0530 Subject: [PATCH 2/5] Fix type check issues --- backend/app/schemas/interview.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/app/schemas/interview.py b/backend/app/schemas/interview.py index 0898f3f..e0876cd 100644 --- a/backend/app/schemas/interview.py +++ b/backend/app/schemas/interview.py @@ -33,7 +33,7 @@ class CustomInterviewBase(BaseModel): dsa_topics: list[DsaTopicCreate] = [] -# Create schema → validation stays here +# Validation should only happen during creation class CustomInterviewCreate(CustomInterviewBase): @model_validator(mode="after") @@ -81,12 +81,12 @@ class Config: from_attributes = True -# Response schema → NO create validation +# Response should not trigger create validation class CustomInterviewResponse(CustomInterviewBase): id: int org_id: int - questions: list[CustomQuestionResponse] = [] - dsa_topics: list[DsaTopicResponse] = [] + questions: list[CustomQuestionResponse] = [] # type: ignore[assignment] + dsa_topics: list[DsaTopicResponse] = [] # type: ignore[assignment] class Config: from_attributes = True From 9200b52e87abddd70a72edc03cee266aa247cac2 Mon Sep 17 00:00:00 2001 From: Nishitha Reddy Date: Wed, 20 May 2026 09:37:14 +0530 Subject: [PATCH 3/5] Fix formatting issue --- backend/app/schemas/interview.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/app/schemas/interview.py b/backend/app/schemas/interview.py index e0876cd..a09e314 100644 --- a/backend/app/schemas/interview.py +++ b/backend/app/schemas/interview.py @@ -107,4 +107,12 @@ class Config: class AppliedInterviewResponse(CustomInterviewBasicResponse): - status: str \ No newline at end of file + status: str + + + + + + + + From 41d5dead81271509db0e8dd597290c71a2128f51 Mon Sep 17 00:00:00 2001 From: Nishitha Reddy Date: Wed, 20 May 2026 09:42:55 +0530 Subject: [PATCH 4/5] Fix trailing whitespace --- backend/app/schemas/interview.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/app/schemas/interview.py b/backend/app/schemas/interview.py index a09e314..731223f 100644 --- a/backend/app/schemas/interview.py +++ b/backend/app/schemas/interview.py @@ -105,11 +105,12 @@ class CustomInterviewBasicResponse(BaseModel): class Config: from_attributes = True - class AppliedInterviewResponse(CustomInterviewBasicResponse): status: str - + + + From eb9868167a086d4564cb719cabbaf8c9b5a12b85 Mon Sep 17 00:00:00 2001 From: Nishitha Reddy Date: Wed, 20 May 2026 09:47:59 +0530 Subject: [PATCH 5/5] Apply ruff formatting --- backend/app/schemas/interview.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/backend/app/schemas/interview.py b/backend/app/schemas/interview.py index 731223f..4dab914 100644 --- a/backend/app/schemas/interview.py +++ b/backend/app/schemas/interview.py @@ -35,7 +35,6 @@ class CustomInterviewBase(BaseModel): # Validation should only happen during creation class CustomInterviewCreate(CustomInterviewBase): - @model_validator(mode="after") def validate_times_and_scores(self) -> "CustomInterviewCreate": tz = self.start_time.tzinfo @@ -58,9 +57,7 @@ def validate_times_and_scores(self) -> "CustomInterviewCreate": dev = self.dev_score or 0 if dsa + dev != 100: - raise BadRequestError( - "The sum of dsa_score and dev_score must be exactly 100" - ) + raise BadRequestError("The sum of dsa_score and dev_score must be exactly 100") return self @@ -105,15 +102,6 @@ class CustomInterviewBasicResponse(BaseModel): class Config: from_attributes = True + class AppliedInterviewResponse(CustomInterviewBasicResponse): status: str - - - - - - - - - -