refactor: simplify connected_agents remapping logic in migration script#863
Conversation
| // Keyed by agent name — remap to bridge_id | ||
| remapped[bridgeId] = agent_info; | ||
| changed = true; | ||
| // No bridge_id — drop orphaned entry | ||
| } |
There was a problem hiding this comment.
This code will use undefined as an object key if bridgeId is undefined, which could lead to data loss or unexpected behavior. Consider adding a check to ensure bridgeId exists before using it as a key.
| // Keyed by agent name — remap to bridge_id | |
| remapped[bridgeId] = agent_info; | |
| changed = true; | |
| // No bridge_id — drop orphaned entry | |
| } | |
| if (bridgeId) { | |
| remapped[bridgeId] = agent_info; | |
| changed = true; | |
| } | |
| // No bridge_id — drop orphaned entry |
| remapped[bridgeId] = agent_info; | ||
| changed = true; |
There was a problem hiding this comment.
The function now unconditionally sets changed = true for every agent_info processed, which could cause the function to return remapped objects even when no actual changes were made. Consider setting changed = true only when a valid bridgeId exists.
| // Keyed by agent name — remap to bridge_id | ||
| remapped[bridgeId] = agent_info; | ||
| changed = true; | ||
| // No bridge_id — drop orphaned entry |
There was a problem hiding this comment.
The comment "No bridge_id — drop orphaned entry" is now misleading since the code no longer implements this behavior. The current implementation will actually add entries with undefined keys rather than dropping orphaned entries.
No description provided.