fix: copilot breaking change introduced in 2.8.5#2647
Conversation
|
The issue seems to be the following: 2.8.4 (works): @sio.on("connect") # pyright: ignore [reportOptionalCall] 2.8.5 (broken): @sio.on("connect") # pyright: ignore [reportOptionalCall] |
|
@jbcallaghan These are just type annotations, they are ignored by Python at runtime.
can only be caused by passing non-existing thread ID to get_thread_author Can you tell what value it has? Like a |
Sorry, that was a red herring. At first I thought that the token wasn't being retrieved, but it is. I tried the following in socket.py and the user details are definitely being retrieved. @sio.on("connect") # pyright: ignore [reportOptionalCall] The issue occurs here, where the user.identifier is populated, there is a thread_id value, but the ChainlitDataLayer can't find the thread in the DB: ChainlitDataLayer raises the error below as there is no matching thread in the DB at this stage when using co-pilot mode. |
|
In answer to your question, this is an example of the thread value: ValueError: Thread d7472f51-b3d2-4361-835d-04a54c3f8cb0 not found |
|
The following mod works, checking the clientType to see if it is copilot. @sio.on("connect") # pyright: ignore [reportOptionalCall] |
There was a problem hiding this comment.
4 issues found across 7 files
Prompt for AI agents (all 4 issues)
Understand the root cause of the following 4 issues and fix them.
<file name="cypress/e2e/data_layer/spec.cy.ts">
<violation number="1" location="cypress/e2e/data_layer/spec.cy.ts:234">
The new access-control test asserts on the UI right after `startNewThread()` without waiting for the `@threadHijack` intercept to fire. Without a `cy.wait('@threadHijack')`, the hijack request might never be sent before the assertion, so the test can report success even if a stolen thread loads, defeating the purpose of the security regression.</violation>
</file>
<file name="backend/chainlit/socket.py">
<violation number="1" location="backend/chainlit/socket.py:137">
Connections with a threadId now proceed when the data layer is unavailable, skipping the previous authorization denial and allowing unvalidated thread access.</violation>
</file>
<file name="cypress/e2e/auth/spec.cy.ts">
<violation number="1" location="cypress/e2e/auth/spec.cy.ts:45">
This test waits on `@user`, but the alias is registered after the page has already loaded `/user` (support/e2e.ts visits `/` before every test) and the test never re-triggers the request, so the wait can never resolve. Move the intercept before a fresh `cy.visit('/')` or force another `/user` request before waiting.</violation>
<violation number="2" location="cypress/e2e/auth/spec.cy.ts:79">
The `/user` alias is registered only after the global `cy.visit('/')` has already fired the request, and the test never causes another `/user` call before `cy.wait('@user')`. As written this test always times out; register the intercept before a new navigation or explicitly trigger `/user` again before waiting.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
There was a problem hiding this comment.
1 issue found across 2 files (reviewed changes from recent commits).
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="cypress/e2e/data_layer/main.py">
<violation number="1" location="cypress/e2e/data_layer/main.py:160">
get_thread_author now assumes the thread exists and will crash with a TypeError if the thread cannot be found. Ensure the result of get_thread is validated before reading userIdentifier.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
Fixes #2641