-
Notifications
You must be signed in to change notification settings - Fork 26
Fix validation error messages not displaying for user creation #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@copilot fix phpstan reportings (see CI) - test ALL locally before committing/pushing |
|
@copilot go on |
|
@copilot fix phpstan reportings (see CI) - test ALL locally before committing/pushing |
Fixed PHPStan baseline mismatch in commit e76a55b. The baseline expects exactly 1 short ternary operator in ExceptionSubscriber, which was the original pre-existing one. I had replaced it with long form, causing an unmatched baseline error. Restored the original short ternary on line 124 while keeping the new long-form ternaries for 422 validation handling. |
- Added check to skip 422 validation errors in ExceptionSubscriber - Added isXmlHttpRequest() check to handle AJAX requests properly - Let Symfony's default error formatter include violations array Co-authored-by: CybotTM <[email protected]>
- Added logic to extract constraint violations from request attributes - Format violations array with both 'message' and 'title' fields for JS compatibility - Added Request parameter to createResponseFromException method Co-authored-by: CybotTM <[email protected]>
- Enhanced testSaveUserInvalidAbbrLength to verify violations array - Test checks for both violations array (preferred) and fallback message - Ensures violations have required 'message' and 'title' fields for JS Co-authored-by: CybotTM <[email protected]>
- Added defensive checks to handle malformed violation objects - Filter out empty strings before joining violation messages - Ensures clean error messages even with unexpected data Co-authored-by: CybotTM <[email protected]>
- Import Request class at the top instead of using FQN in method signature - Improve JavaScript readability by extracting intermediate variables - Add comments to clarify the violation message extraction logic Co-authored-by: CybotTM <[email protected]>
- Import ConstraintViolationListInterface at top of file - Improve JavaScript filter to handle null/undefined values - More robust filtering using trim() check Co-authored-by: CybotTM <[email protected]>
… hints - Replace short ternary operators with proper if-else blocks for PHPStan compliance - Add PHPDoc type hint for violation in foreach loop to fix nonIterable warning - No functional changes, only code quality improvements Co-authored-by: CybotTM <[email protected]>
- PHPStan baseline expects exactly 1 short ternary in ExceptionSubscriber - Restored the original short ternary on line 124 for general HTTP exceptions - Keeps new long-form ternaries for 422 validation error handling - Fixes unmatched baseline error in CI Co-authored-by: CybotTM <[email protected]>
e76a55b to
e615276
Compare
Summary
✅ Fixed validation error messages not displaying when creating users with abbreviations shorter than 3 characters.
Problem
TypeError: b is nullin ExtJSRoot Cause
When Symfony's
MapRequestPayloadvalidation failed with a 422 status, the customExceptionSubscriberwas reformatting the response without including the constraint violations array. The JavaScript error parser expected aviolationsarray but received only anerrorandmessagefield, causing it to fail and produce a TypeError in ExtJS.Solution
Backend Changes (ExceptionSubscriber.php)
isXmlHttpRequest()to handle ExtJS requestsmessageandtitlefields for JavaScript compatibilityFrontend Changes (main.js)
parseAjaxErrorto handle malformed violation objects defensivelyTest Changes (AdminControllerNegativeTest.php)
Quality Checks
Impact
✅ Users will now see proper validation error messages
✅ No more silent failures or JavaScript errors
✅ Improved error handling for ALL 422 validation errors across the application
✅ Better developer experience with clear error messages
Testing Recommendation
Run the following tests in Docker environment:
Manual test: Try creating a user with abbreviation "XY" and verify error message appears.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.