Skip to content

Conversation

@octoaide
Copy link
Contributor

@octoaide octoaide bot commented Jan 22, 2026

Closes #681

Summary

This PR adds application-level validation to ensure a single customer cannot register the same network range more than once. The check uses exact equality on HostNetworkGroup values (as requested in the issue) and runs both when inserting a new Customer and when updating an existing Customer's networks.

What changed

  • src/tables/customer.rs

    • Added helper function find_duplicate_network_group to detect duplicate HostNetworkGroup values within a customer's networks.
    • Added validation during IndexedTable::insert to reject inserts containing duplicate network ranges for the same customer.
    • Added validation in Update::apply so updates to the networks field are validated and duplicate ranges are rejected.
    • Added unit tests covering:
      • insert_with_duplicate_network_range_fails
      • insert_with_different_network_ranges_succeeds
      • update_with_duplicate_network_range_fails
      • update_with_different_network_ranges_succeeds
      • different_customers_can_have_same_network_range
  • CHANGELOG.md

    • Added an Unreleased entry documenting the new validation.

Why

The system previously allowed registering identical network ranges under the same customer when network names differed. This change enforces uniqueness per-customer to prevent duplicate network entries and the potential confusion or conflicts they cause. The validation is implemented at the application level (no DB migration) and uses exact equality semantics as specified.

Notes

  • Error message when a duplicate is detected: "network range already exists for this customer (duplicate in network "")".
  • Different customers may still have the same network range; the uniqueness is enforced per-customer only.

Related

Issue: #681

 2 files changed, 286 insertions(+), 3 deletions(-)

Automated changes made by octoaide bot.
@octoaide octoaide bot requested a review from pott-cho January 22, 2026 18:44
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.11%. Comparing base (ddda2af) to head (e580415).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
+ Coverage   80.90%   81.11%   +0.21%     
==========================================
  Files          83       83              
  Lines       23358    23413      +55     
==========================================
+ Hits        18897    18992      +95     
+ Misses       4461     4421      -40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Add Validation to Prevent Duplicate Network Ranges per Customer

1 participant