WikiEduDashboard
WikiEduDashboard copied to clipboard
Fix: #6087 Display specific error message for course slug collision (revision)
What this PR does
(Revision) Fixes https://github.com/WikiEducationFoundation/WikiEduDashboard/issues/6087
This PR addresses the issue where a generic "Internal Server Error" message was displayed when a user attempted to change a course slug to one that already existed.
Screenshots
Before:
This is an error occurring not showing proper message only showing Internal Server Error
Course titles can be identical for different organizations or institutions, but must be unique within the same organization or institution. This is because course titles are used to dynamically generate URLs (slugs), and duplicate titles within the same organization would create URL conflicts.
look: below
After:
Showing proper message
Updated
Just a suggestion, Displaying the existing course slug as a clickable link opening that existing course in a new tab so that users can easily identify which course it is colliding with by clicking on it. This will enhance clarity and user experience. What do you think?
Just a suggestion, Displaying the existing course slug as a clickable link opening that existing course in a new tab so that users can easily identify which course it is colliding with by clicking on it. This will enhance clarity and user experience. What do you think?
It can be implemented, but the primary goal is to provide a clear and accurate message so that the user can choose a different slug.
It looks like a test broke because of this new validation. You likely need to make a slight adjustment to that test so that it doesn't trigger the duplicate slug error.
It looks like a test broke because of this new validation. You likely need to make a slight adjustment to that test so that it doesn't trigger the duplicate slug error.
@ragesoss
This is before adding any tests
This is after adding tests
This means below error or ruby rspec test suit fail is not because of my code. but for additional, I added tests as you said
In the below, all three already merged pulls have the same error in building
This is happening because of different code in the codebase or May be I am wrong but I think this is happening because of version conflict why I am saying, look below pictures
look in our codebase below the picture
but we are using this
Conclusion: As you mentioned, I added tests and verified them. The Ruby RSpec test suite failure is likely due to differences in the codebase unrelated to my changes or possibly for the reasons I explained earlier with the provided screenshots. Let me know if you need further improvement.
Have a look at the failed test run for this PR: https://github.com/WikiEducationFoundation/WikiEduDashboard/actions/runs/13287364003/job/37124931915
It's different from the ones in your screenshots, and the error is the course duplicate slug error. Run that test locally and see if you can replicate the failure.
Have a look at the failed test run for this PR: https://github.com/WikiEducationFoundation/WikiEduDashboard/actions/runs/13287364003/job/37124931915
It's different from the ones in your screenshots, and the error is the course duplicate slug error. Run that test locally and see if you can replicate the failure.
@ragesoss Yes, sir, you were right. The error was caused by the new validation for duplicate slug errors. I have fixed it and attached the screenshots. Additionally, I have added tests for the new validation. Please review and let me know if any further improvements are needed. Thanks!
before
after
@ragesoss I have made changes please review and let me know if need any further improvement
Thanks! On further reflection, I'm not sure that using a validation is the right strategy here, since we already enforce unique slugs at the database level. With the validation, we'll be making an extra query every time we call Course#update. I think a better strategy would be to just rescue the database error that occurs without the validation, rather than rescuing an error thrown by the validation.