commit 865c29f4dec268da53ccc290217c957307275a93
parent 507c948ed8bb927096c6951ef75d8398fae040f9
Author: Joel Challis <git@zvecr.com>
Date: Thu, 17 Jul 2025 13:36:04 +0100
Ensure keyboard aliases do not point to themselves (#25500)
Diffstat:
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/lib/python/qmk/cli/ci/validate_aliases.py b/lib/python/qmk/cli/ci/validate_aliases.py
@@ -25,6 +25,21 @@ def _target_keyboard_exists(target):
return True
+def _alias_not_self(alias):
+ """Check if alias points to itself, either directly or within a circular reference
+ """
+ aliases = keyboard_alias_definitions()
+
+ found = set()
+ while alias in aliases:
+ found.add(alias)
+ alias = aliases[alias].get('target', alias)
+ if alias in found:
+ return False
+
+ return True
+
+
@cli.subcommand('Validates the list of keyboard aliases.', hidden=True)
def ci_validate_aliases(cli):
aliases = keyboard_alias_definitions()
@@ -32,7 +47,11 @@ def ci_validate_aliases(cli):
success = True
for alias in aliases.keys():
target = aliases[alias].get('target', None)
- if not _target_keyboard_exists(target):
+ if not _alias_not_self(alias):
+ cli.log.error(f'Keyboard alias {alias} should not point to itself')
+ success = False
+
+ elif not _target_keyboard_exists(target):
cli.log.error(f'Keyboard alias {alias} has a target that doesn\'t exist: {target}')
success = False