Skip to content

fix: read the camelCase keys of the roomConfig claim - #1244

Open
RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/jwt-room-config-claim-keys
Open

RaphaelFakhri wants to merge 1 commit into
livekit:mainfrom
RaphaelFakhri:fix/jwt-room-config-claim-keys

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

Summary

Fixes #1243.

RoomConfiguration and RoomAgentDispatch read only snake_case keys such as agent_name, empty_timeout and max_participants. That matches the token endpoint request format, but LiveKit tokens write the roomConfig claim as protobuf JSON with camelCase keys (agentName, emptyTimeout, maxParticipants). The Go (protojson.Marshal in livekit/protocol auth/grants.go), Python (MessageToDict) and Node server SDKs all produce camelCase keys. As a result, TokenSourceResponse.jwtPayload?.roomConfiguration returned null for every field except name, metadata and the agents list, and each agent had a null agentName.

This change:

  • Makes RoomConfiguration.fromJson and RoomAgentDispatch.fromJson fall back to the camelCase key when the snake_case key is absent, the same way TokenSourceResponse.fromJson already accepts both forms.
  • Leaves toJson unchanged, so token endpoint requests still use snake_case keys.

Test plan

  • test/token/token_source_test.dart: the new parses room configuration from the camelCase keys of the roomConfig claim test builds a token with the keys that LiveKit tokens use and checks every field.
  • Before the change the test fails with Expected: <300>, Actual: <null> on config.emptyTimeout. After the change it passes.
  • The existing snake_case test still passes.
  • flutter test, flutter analyze, dart format --set-exit-if-changed and import_sorter pass.
  • Added a .changes entry.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jwtPayload.roomConfiguration returns null fields for tokens from LiveKit server SDKs

1 participant