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

Duplicate roll numbers can be added in add_student due to incorrect comparison of roll numbers as strings instead of integers. #15

Open
2 tasks
Advaitgaur004 opened this issue Oct 25, 2024 · 0 comments
Labels
bugbounty Bug Bounty event hosted by Devlup Labs, inviting developers to identify and report bugs good first issue Good for newcomers

Comments

@Advaitgaur004
Copy link
Member

Description

The add_student function does not properly check for duplicate roll numbers due to incorrect comparison of roll numbers as strings instead of integers, allowing duplicates to be added.

Files

List the relevant files associated with this issue. This will guide contributors in navigating the project effectively and provide clues on where to start.

To Reproduce

  1. Initialize the StudentManagementSystem class.
  2. Call the add_student method with a roll number as a string (e.g., "001").
  3. Call the add_student method again with the same roll number as an integer (e.g., 1).
  4. Observe that both students are added despite having the same roll number.

Expected Behavior

The add_student function should reject the addition of a new student with a roll number that already exists in the system.

Actual Behavior

The function accepts both roll numbers as different due to string comparison, allowing duplicate entries.

Tasks

  • Modify the duplicate roll number check in the add_student method to compare roll numbers as integers.
  • Update any affected tests or add new ones if necessary.

Possible Fixes

Change the comparison in add_student fromstr(student.roll_no) == str(roll_no) to student.roll_no == roll_no to ensure both are compared as integers.

@Advaitgaur004 Advaitgaur004 added bugbounty Bug Bounty event hosted by Devlup Labs, inviting developers to identify and report bugs good first issue Good for newcomers labels Oct 25, 2024
@Advaitgaur004 Advaitgaur004 mentioned this issue Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugbounty Bug Bounty event hosted by Devlup Labs, inviting developers to identify and report bugs good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant