add can_update_own_metadata to simulate_job token#5294
Open
quoctuanck99 wants to merge 1 commit intolivekit:mainfrom
Open
add can_update_own_metadata to simulate_job token#5294quoctuanck99 wants to merge 1 commit intolivekit:mainfrom
quoctuanck99 wants to merge 1 commit intolivekit:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an agent is run in
connectordevmode, callingctx.agent.set_name(),ctx.agent.set_metadata(), orctx.agent.set_attributes()has no effect and does not raise an error.Steps to Reproduce
Run with:
Expected result:
The participant name is updated to
"new_name"in the room.Actual result:
The name remains unchanged (default value is
""), and no error is raised.The same code works as expected when the job is started via:
Root Cause
simulate_job()inworker.pygenerates a local JWT for simulated jobs, but the token does not includecan_update_own_metadata.That permission is required for:
set_name()set_metadata()set_attributes()This is also consistent with the note in
participant.py.When the job is dispatched normally by the server, the generated token includes this grant automatically, which explains why the behavior differs between
connect/devmode andstart.Proposed Fix
In
simulate_job(), update:to:
Note
I am not sure whether omitting this grant in simulated/dev jobs was intentional, for example as a security boundary to prevent metadata updates in those modes.
If this behavior is intentional, please feel free to close the PR. In that case, I would appreciate a short note on the rationale so I can handle it appropriately on my side.