Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/malformed-agent-attributes-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"client-sdk-android": patch
---

Fix a crash when a participant's `lk.agent.inputs` or `lk.agent.outputs` attribute is not a valid JSON array. The attribute is now logged as a warning and the participant's agent attributes are left unchanged.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import io.livekit.android.room.track.TrackPublication
import io.livekit.android.room.types.AgentAttributes
import io.livekit.android.room.types.fromStringMap
import io.livekit.android.util.FlowObservable
import io.livekit.android.util.LKLog
import io.livekit.android.util.diffMapChange
import io.livekit.android.util.flow
import io.livekit.android.util.flowDelegate
Expand Down Expand Up @@ -459,7 +460,11 @@ open class Participant(
permissions = ParticipantPermission.fromProto(info.permission)
}
attributes = info.attributesMap
agentAttributes = AgentAttributes.fromStringMap(info.attributesMap)
try {
agentAttributes = AgentAttributes.fromStringMap(info.attributesMap)
} catch (e: Exception) {
LKLog.w(e) { "Failed to parse agent attributes for participant ${info.identity}" }
}
state = State.fromProto(info.state)
clientProtocol = info.clientProtocol
capabilities = info.capabilitiesList.mapNotNull { ClientCapability.fromProto(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,27 @@ class RoomMockE2ETest : MockE2ETest() {
)
}

@Test
fun participantConnectedWithMalformedAgentAttributes() = runTest {
connect()

val participantJoin = with(TestData.PARTICIPANT_JOIN.toBuilder()) {
update = with(update.toBuilder()) {
setParticipants(
0,
TestData.REMOTE_PARTICIPANT.toBuilder()
.putAttributes("lk.agent.inputs", "not json")
.build(),
)
build()
}
build()
}
simulateMessageFromServer(participantJoin)

assertNotNull(room.getParticipantBySid(TestData.REMOTE_PARTICIPANT.sid))
}

@Test
fun participantSubscribesRemoteTrack() = runTest {
connect()
Expand Down
Loading