Skip to content
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

Fix: #6087 Display specific error message for course slug collision #6165

Conversation

ichandrasharma
Copy link

What this PR does

Fixes #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.

Key changes in code :
Backend (Rails): Modified the Rails controller to send a JSON response containing a specific error message when a course slug collision occurs. This message clarifies the reason for the error to the user.

Frontend: Updated the frontend code to correctly extract and display the specific error message received from the backend. This replaces the generic "Internal Server Error" message with a user-friendly message indicating the slug collision.

Screenshots

Before:
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)

and this is an error occurring not showing proper message only showing Internal Server Error
Screenshot (69)

After:
Showing proper message
Screenshot (71)

And should be a different title to avoid conflict in the URL
Screenshot (72)

Learning

I took 3+ days to understand the codebase, and then I solved this

import CourseUtils from '../utils/course_utils';
import request from '../utils/request';
import { toWikiDomain } from '../utils/wiki_utils';
ADD_NOTIFICATION,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep functional changes separate from formatting changes. I don't mind changes that apply this sort of formatting change, but they should be done in a separate PR with a clear description of how they were done (eg, automatically via a linter in VSCode, or whatever). It's much harder to think through and review functional changes when they are mixed in with major formatting changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will off my automatically linter then I change a pr then and anything should be done

@ragesoss
Copy link
Member

Thanks! For the error message, ideally it should display just the message itself, without the json formatting.

@ichandrasharma ichandrasharma deleted the fix-course-slug-error branch February 1, 2025 18:01
@ichandrasharma ichandrasharma restored the fix-course-slug-error branch February 1, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error message from course slug collision does not explain the problem
2 participants