From 0b824f8cd270c1443ae3611add632c5489429eee Mon Sep 17 00:00:00 2001 From: ypratama Date: Wed, 9 Sep 2026 13:57:52 +0700 Subject: [PATCH] Fix: prioritize protected_label in agents/list API to prevent proxy overwrite bug on devices and view-as dropdown --- backend/routes/dashboard/agents.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/routes/dashboard/agents.js b/backend/routes/dashboard/agents.js index add0df7..f683274 100644 --- a/backend/routes/dashboard/agents.js +++ b/backend/routes/dashboard/agents.js @@ -214,11 +214,17 @@ router.get('/agents/list', async (req, res) => { const agents = await db.collection('agent_registry') .find(filter) - .project({ uuid: 1, label: 1, _id: 0 }) + .project({ uuid: 1, label: 1, protected_label: 1, _id: 0 }) .sort({ uuid: 1 }) .toArray(); - - res.json({ ok: true, data: agents }); + + // Use protected_label if available to prevent proxy overwrite bug + const mappedAgents = agents.map(a => ({ + uuid: a.uuid, + label: a.protected_label || a.label || a.uuid + })); + + res.json({ ok: true, data: mappedAgents }); } catch (err) { res.status(500).json({ ok: false, error: err.message }); }