-
-
Notifications
You must be signed in to change notification settings - Fork 335
Description
Describe the bug:
When attempting to save a new threat model with a name that already exists in the repository, the application returns a 500 server error instead of providing a user-friendly validation message. This occurs because GitHub's API requires a SHA parameter when updating existing files, but the application is sending a create request without one.
Expected behaviour:
When a user tries to save a threat model with a name that already exists:
- The application should detect the duplicate name before attempting the API call
- Display a clear error message: "A threat model with this name already exists. Please choose a different name."
- Allow the user to modify the name without losing their work
- Alternatively, offer to update/overwrite the existing file with user confirmation
Environment:
- Version: 2.5
- Platform: Web App
- OS: Windows
- Browser: Chrome
To Reproduce:
- Log in with GitHub provider
- Select a repository and branch
- Create a new threat model with name "Test Model"
- Save successfully
- Create another threat model with the same name "Test Model"
- Attempt to save
- Observe 500 error response
Declaration:
By submitting this issue you have:
- read the contribution guide and agree to the Code of Conduct
- not used agentic or generative AI in creating this bug report
The screenshot above shows the threat models already saved in my branch.
As shown above, when attempting to create a new threat model with the duplicate name , the application returns a 500 server error with no actionable feedback or guidance.
Suggested Fix:
Before attempting to save a new threat model:
- Check if a threat model with the same name already exists in the selected branch (this can be done with checking the models array which exists in the state)
- If duplicate detected, show validation error with clear message
- Prevent the API call from being made
Alternatively, catch the 500 error response and transform it into a user-friendly message.