Feat/test ci cd#92
Conversation
📝 WalkthroughWalkthroughRequest contracts now accept curriculum as a JSON string instead of a strongly-typed list. Endpoint handlers deserialize that string into ChangesCurriculum JSON Binding and Deserialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/Src/PIED_LMS.Presentation/APIs/CourseEndpoints.cs`:
- Around line 81-83: Wrap the inline deserialization of request.Curriculum in
both CreateCourse and UpdateCourse with a try/catch that specifically catches
System.Text.Json.JsonException; if caught, return a client error ServiceResponse
(e.g., a 400 BadRequest/validation response) instead of allowing the exception
to propagate to mediator.Send/global handler, so malformed JSON yields a
deterministic validation error. Ensure you reference the same JsonSerializer
call that deserializes into List<CurriculumSectionDto> and return the
ServiceResponse from the endpoint method when catching the exception.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ca285a25-db05-4ce5-9ded-358cf6ff693d
⛔ Files ignored due to path filters (3)
backend/Src/PIED_LMS.Persistence/Migrations/20260602155608_UpdateCourseModel.Designer.csis excluded by!**/*.Designer.cs,!**/Migrations/**and included bybackend/Src/**backend/Src/PIED_LMS.Persistence/Migrations/20260602155608_UpdateCourseModel.csis excluded by!**/Migrations/**and included bybackend/Src/**backend/Src/PIED_LMS.Persistence/Migrations/PiedLmsDbContextModelSnapshot.csis excluded by!**/Migrations/**and included bybackend/Src/**
📒 Files selected for processing (2)
backend/Src/PIED_LMS.Contract/Services/Course/Request.csbackend/Src/PIED_LMS.Presentation/APIs/CourseEndpoints.cs
| var curriculumList = string.IsNullOrWhiteSpace(request.Curriculum) | ||
| ? null | ||
| : System.Text.Json.JsonSerializer.Deserialize<List<CurriculumSectionDto>>(request.Curriculum, new System.Text.Json.JsonSerializerOptions { PropertyNameCaseInsensitive = true }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify whether the web pipeline explicitly maps JsonException to HTTP 400.
fd -e cs . backend/Src | xargs rg -n -C3 'JsonException|UseExceptionHandler|IExceptionHandler|ProblemDetails|StatusCodes\.Status400BadRequest'Repository: PiedTeam/pied-lms
Length of output: 13015
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the exact code around the cited deserialization lines in CourseEndpoints.cs
sed -n '60,140p' backend/Src/PIED_LMS.Presentation/APIs/CourseEndpoints.cs
# Inspect GlobalExceptionHandler.cs for JsonException mapping (or lack thereof)
sed -n '1,220p' backend/Src/PIED_LMS.API/Middlewares/GlobalExceptionHandler.csRepository: PiedTeam/pied-lms
Length of output: 5476
Catch System.Text.Json.JsonException for request.Curriculum in both CreateCourse and UpdateCourse.
Both endpoints deserialize request.Curriculum inline (no try/catch), so malformed payloads throw before mediator.Send; GlobalExceptionHandler does not handle JsonException and falls back to 500, not a deterministic client validation response. Catch JsonException in CourseEndpoints.cs (lines 81-83 and 117-119) and return a client error ServiceResponse (e.g., 400 BadRequest / validation) instead of letting it escape to the global handler.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/Src/PIED_LMS.Presentation/APIs/CourseEndpoints.cs` around lines 81 -
83, Wrap the inline deserialization of request.Curriculum in both CreateCourse
and UpdateCourse with a try/catch that specifically catches
System.Text.Json.JsonException; if caught, return a client error ServiceResponse
(e.g., a 400 BadRequest/validation response) instead of allowing the exception
to propagate to mediator.Send/global handler, so malformed JSON yields a
deterministic validation error. Ensure you reference the same JsonSerializer
call that deserializes into List<CurriculumSectionDto> and return the
ServiceResponse from the endpoint method when catching the exception.
Summary by CodeRabbit