Fix: prioritize protected_label in agents/list API to prevent proxy overwrite bug on devices and view-as dropdown
This commit is contained in:
1 parent
bb429ba566
commit
0b824f8cd2
1 file changed
+9
-3
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user