WikiEduDashboard icon indicating copy to clipboard operation
WikiEduDashboard copied to clipboard

Fix: #6087 Display specific error message for course slug collision (revision)

Open ichandrasharma opened this issue 10 months ago • 7 comments

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 Screenshot (69)

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 Screenshot (70)

After:

Showing proper message Updated Screenshot (75) Screenshot (76)

ichandrasharma avatar Feb 01 '25 18:02 ichandrasharma

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?

JiyaGupta-cs avatar Feb 08 '25 18:02 JiyaGupta-cs

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.

ichandrasharma avatar Feb 08 '25 19:02 ichandrasharma

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 avatar Feb 12 '25 22:02 ragesoss

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 Screenshot (81) Screenshot (82)

This is after adding tests Screenshot (86)

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 Screenshot (87)

In the below, all three already merged pulls have the same error in building Screenshot (88) Screenshot (89)

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 Screenshot (90) Screenshot (91) Screenshot (92)

look in our codebase below the picture Screenshot (93)

but we are using this Screenshot (94)


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.

ichandrasharma avatar Feb 13 '25 10:02 ichandrasharma

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 avatar Feb 13 '25 20:02 ragesoss

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 Screenshot (96) Screenshot (97)

after Screenshot (98)

ichandrasharma avatar Feb 15 '25 04:02 ichandrasharma

@ragesoss I have made changes please review and let me know if need any further improvement

ichandrasharma avatar Feb 19 '25 20:02 ichandrasharma

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.

ragesoss avatar Mar 05 '25 20:03 ragesoss