fix: Enhance validation in controllers and filters to handle missing … - #1201
Conversation
…dataset gracefully
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughControllers and filters now consistently validate that ChangesDataset presence validation and session resilience
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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 |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 `@src/controllers/lpaDetailsController.js`:
- Line 8: The code in lpaDetailsController sets requestId from
req.session?.checkRequestId but falls back only to
req.sessionModel.get('request_id'), while other controllers store/read the
camelCase key; update the fallback logic in lpaDetailsController so requestId is
resolved by checking req.session?.checkRequestId first, then
req.sessionModel.get('requestId') and finally req.sessionModel.get('request_id')
to cover both stored formats; locate the assignment to requestId in
lpaDetailsController and adjust the fallback order accordingly.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8fcdaccc-3937-41f4-8f4c-8b80ebc8a8da
📒 Files selected for processing (9)
src/controllers/CheckAnswersController.jssrc/controllers/datasetDetailsController.jssrc/controllers/lpaDetailsController.jssrc/controllers/pageController.jssrc/filters/makeDatasetSlugToReadableNameFilter.jstest/unit/PageController.test.jstest/unit/checkAnswersController.test.jstest/unit/lpaDetailsController.test.jstest/unit/makeDatasetSlugToReadableNameFilter.test.js
Description
Fixes a submit journey crash where
datasetSlugToReadableNamecould be called with a missing dataset, causingCannot read properties of undefined (reading 'charAt').The submit journey now redirects users back to
/check/urlwhen required session data is missing, and the shared page controller avoids formatting a dataset name unless a dataset exists. The dataset name filter also has a defensive fallback for missing slugs.What type of PR is this? (check all applicable)
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
Run the focused unit tests:
Expected result: all tests pass.
Manual QA:
/submit/lpa-details,/submit/dataset-details, and/submit/check-answersstill render correctly when session data is valid./submit/dataset-detailsor/submit/check-answerswithout a valid submit session./check/urlinstead of seeing a server error.Before
The check answers page could throw:
when
values['dataset']was missing.After
Missing required submit journey data redirects the user to
/check/url, and the dataset name formatter is not called with a missing dataset.Added/updated tests?
QA sign off
[optional] Are there any post-deployment tasks we need to perform?
None.
[optional] Are there any dependencies on other PRs or Work?
None.
Summary by CodeRabbit
Bug Fixes
Tests