From 82177740bcb15a5553aaf7313885b415e7795548 Mon Sep 17 00:00:00 2001 From: Eric Fahlgren Date: Thu, 26 Mar 2026 09:51:33 -0700 Subject: [PATCH] util: work around broken device naming There are a number of broken device specifications that redundantly map various images to the same device names. Handle most of these by ensuring that the actual device name maps to itself, rather than some arbitrary value in 'SUPPORTED_DEVICES' due to these incorrect device mappings in the profiles.json. Fixes: https://github.com/openwrt/openwrt/issues/22541 Signed-off-by: Eric Fahlgren --- asu/util.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/asu/util.py b/asu/util.py index 4d3557d8..87fd30ca 100644 --- a/asu/util.py +++ b/asu/util.py @@ -642,12 +642,25 @@ def reload_profiles(app: FastAPI, version: str, target: str) -> bool: settings.upstream_url + f"/{version_path}/targets/{target}/profiles.json" ) - app.profiles[version][target] = { + profiles = { name.replace(",", "_"): profile for profile, data in response.json()["profiles"].items() for name in data.get("supported_devices", []) + [profile] } + # Eliminate any remapping to alternate supported profiles. Must happen + # /after/ all of above to avoid order-of-listing problems. Also log an + # error message about the improperly defined profiles, as this indicates + # a bug in the Device definitions. + for profile in response.json()["profiles"]: + if profiles[profile] != profile: + # Here's what we should log, but we don't have a good "log once" + # mechanism yet, and don't want to flood the logs. + # f"ERROR: profile bug {version} {target} {profile} mapped to {profiles[profile]}" + profiles[profile] = profile + + app.profiles[version][target] = profiles + return True