Skip to content

fix: prevent adding cameras with invalid model names (#1162)#1165

Open
COZYTRICKSTER wants to merge 6 commits intoopen-edge-platform:release-2025.2from
COZYTRICKSTER:fix-camera-model-validation
Open

fix: prevent adding cameras with invalid model names (#1162)#1165
COZYTRICKSTER wants to merge 6 commits intoopen-edge-platform:release-2025.2from
COZYTRICKSTER:fix-camera-model-validation

Conversation

@COZYTRICKSTER
Copy link
Copy Markdown

📝 Description

When adding a camera, the system allowed specifying a model name that does not exist in the configured model list (model-config). The camera would still be created successfully even though the model was invalid.

This could result in a confusing state where:

  • The camera appears in the system
  • No video feed is processed
  • No object tracking appears on the GUI

This change introduces validation during camera creation to ensure that the provided model name exists in model-config. If the model is not found, the request is rejected with a validation error.

Fixes #1162


🔍 Behavior Before / After

Before

  • Cameras could be created with invalid model names that were not present in model-config.
  • The camera would appear in the system but no feed or tracking would be available on the GUI.

After

  • The system validates the model name during camera creation.
  • If the specified model does not exist in model-config, the request is rejected with an appropriate validation error.

✨ Type of Change

  • 🐞 Bug fix – Non-breaking change which fixes an issue
  • 🚀 New feature – Non-breaking change which adds functionality
  • 🔨 Refactor – Non-breaking change which refactors the code base
  • 💥 Breaking change – Changes that break existing functionality
  • 📚 Documentation update
  • 🔒 Security update
  • 🧪 Tests
  • 🚂 CI

🧪 Testing Scenarios

  • ✅ Tested manually
  • 🤖 Ran automated end-to-end tests

Tested locally by attempting to add a camera with both valid and invalid model names. Verified that:

  • Cameras with valid models are created successfully.
  • Cameras with invalid model names are rejected with a validation error.

✅ Checklist

  • 🔍 PR title is clear and descriptive
  • 📝 For internal contributors: If applicable, include the JIRA ticket number in the PR title
  • 💬 I have commented my code, especially in hard-to-understand areas
  • 📄 I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or my feature works

@COZYTRICKSTER
Copy link
Copy Markdown
Author

Test Results


Sharing screenshots from testing to demonstrate the behavior before and after the fix.

In this example, I attempted to add a camera with the model pv2000, which is not present in model-config.

Before Fix

  • The system allowed adding a camera with a model name that was not present in model-config.
  • The camera was created but no incoming feed appeared in the GUI.
image

After Fix

  • The system now validates the model name against model-config when adding a camera.
  • If the model does not exist, the request is rejected with a validation error, preventing the camera from being created.
image

Copy link
Copy Markdown
Contributor

@tdorauintc tdorauintc left a comment

Choose a reason for hiding this comment

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

@COZYTRICKSTER thank you for your contribution.
For the sake of code maintainability and reliability, I would advice to try to reuse existing code for validation. Please see my comments.

Replace manual model validation in CamCreateForm.clean_camerachain()
with parse_model_chain() from ppl_generator. This aligns validation
with the existing pipeline parser and ensures future compatibility
with potential chain syntax changes.

Also includes minor indentation fixes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds server-side validation to prevent cameras being created with a camerachain that references models not present in the configured model-config, avoiding “camera exists but nothing processes/tracks” states.

Changes:

  • Add CamCreateForm.clean_camerachain() validation that parses the model chain against model_config.json and rejects invalid models.
  • Override CamCreateView.form_invalid() to return HTTP 400 on validation failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
manager/src/django/forms.py Adds camerachain validation by loading model-config and calling parse_model_chain() during camera creation.
manager/src/django/views.py Returns 400 status for invalid camera-create form submissions.

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.

4 participants