Skip to content

Conversation

@ianbbqzy
Copy link

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Ian Lee seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

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

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 potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 request_id variable overwritten, breaking traceability in error reports

In ChunkedStream._run(), the request_id variable is assigned a UUID at line 1003 for use as the X-Request-Id HTTP header, but then immediately overwritten at line 1018 with utils.shortuuid() for the emitter's request_id. This means that when errors are reported at lines 1051 and 1058, the request_id passed to APIStatusError is the shortuuid, not the UUID that was actually sent to the server in the X-Request-Id header.

Root Cause and Impact

The PR introduces request_id = str(uuid.uuid4()) at line 1003 for the X-Request-Id header, but the pre-existing request_id = utils.shortuuid() at line 1018 overwrites it:

request_id = str(uuid.uuid4())       # line 1003 - UUID for X-Request-Id header
async with self._tts._ensure_session().post(
    ...,
    headers={"X-Request-Id": request_id},  # line 1009 - UUID sent to server
) as resp:
    request_id = utils.shortuuid()     # line 1018 - OVERWRITES with shortuuid
    ...
    raise APIStatusError(
        request_id=request_id,          # line 1051 - now shortuuid, not UUID!
    )

Impact: The whole purpose of this PR is to add X-Request-Id for better traceability. When an error occurs during response processing, the request_id reported in the exception is a different value than what was sent to the server, defeating the traceability goal. The server-side X-Request-Id UUID cannot be correlated with the client-side error.

The fix should use a different variable name for one of the two IDs, e.g. http_request_id for the header UUID and keep request_id for the emitter.

(Refers to line 1018)

Prompt for agents
In livekit-plugins/livekit-plugins-inworld/livekit/plugins/inworld/tts.py, the `request_id` variable in `ChunkedStream._run()` is used for two different purposes: (1) as the X-Request-Id HTTP header value (UUID, line 1003) and (2) as the emitter's request_id (shortuuid, line 1018). The second assignment overwrites the first, so error handlers at lines 1051 and 1058 report the wrong ID.

To fix this, rename the header variable at line 1003 to something like `http_request_id` and use it only for the header at line 1009. Keep the existing `request_id = utils.shortuuid()` at line 1018 for the emitter and error reporting. Alternatively, use the UUID for both purposes (remove line 1018 and use the UUID everywhere), depending on whether the emitter needs a shortuuid specifically.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

2 participants