Skip to content

Creating threat model with duplicate name returns 500 error instead of validation message #1435

@Ajith-Penmatsa-GGL

Description

@Ajith-Penmatsa-GGL

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:

  1. The application should detect the duplicate name before attempting the API call
  2. Display a clear error message: "A threat model with this name already exists. Please choose a different name."
  3. Allow the user to modify the name without losing their work
  4. Alternatively, offer to update/overwrite the existing file with user confirmation

Environment:

  • Version: 2.5
  • Platform: Web App
  • OS: Windows
  • Browser: Chrome

To Reproduce:

  1. Log in with GitHub provider
  2. Select a repository and branch
  3. Create a new threat model with name "Test Model"
  4. Save successfully
  5. Create another threat model with the same name "Test Model"
  6. Attempt to save
  7. Observe 500 error response

Declaration:

By submitting this issue you have:

Image

The screenshot above shows the threat models already saved in my branch.

Image

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:

  1. 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)
  2. If duplicate detected, show validation error with clear message
  3. Prevent the API call from being made

Alternatively, catch the 500 error response and transform it into a user-friendly message.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions