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

@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.10%. Comparing base (ddda2af) to head (63a9a12).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
+ Coverage   80.90%   81.10%   +0.20%     
==========================================
  Files          83       83              
  Lines       23358    23403      +45     
==========================================
+ Hits        18897    18982      +85     
+ 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.

@pott-cho pott-cho force-pushed the octoaide/issue-681-2026-01-22T18-07-19 branch from e2c6020 to 4415a39 Compare January 23, 2026 09:34
@pott-cho pott-cho force-pushed the octoaide/issue-681-2026-01-22T18-07-19 branch from 4415a39 to 63a9a12 Compare January 23, 2026 09:47
@pott-cho
Copy link

The following changes have been added.

  • Refactored duplicated code in the code generated by Octoaide.
  • Removed context("invalid update") from new_entry.context("invalid update")? so that duplicate error messages are propagated to the upper layer as-is.

@sophie-cluml sophie-cluml self-requested a review January 28, 2026 09:22
Copy link
Contributor

@sophie-cluml sophie-cluml left a comment

Choose a reason for hiding this comment

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

Discussion is underway in another private channel.

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

2 participants