-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Problem
The ansible_name column added in PR #1932 (#1814) has no uniqueness constraint in the database model and no min_length validation in the Pydantic schema.
Uniqueness
Two nodes could have the same ansible_name, causing Ansible --limit to target the wrong node (or both). Since ansible_name is used for --limit targeting and Ansible inventory host keys, duplicates would cause silent misrouting of playbook executions.
Validation
NodeUpdate.ansible_name accepts any string including empty string "". While "" is falsy in Python's or operator (so the ansible_target property falls back to IP), an explicit Field(min_length=1) would prevent confusion.
Discovered During
Implementation of #1986 (ansible_name auto-populate from heartbeat)
Fix
- Add
UniqueConstraintor unique index onansible_name(nullable unique — NULL is allowed, duplicates are not) - Add
Field(min_length=1)toNodeUpdate.ansible_nameandNodeCreate.ansible_name - Add migration for the unique constraint
Impact
Severity: medium — Silent misrouting of Ansible commands if duplicates exist.