Skip to content

Commit 53f6847

Browse files
committed
fix(simulate): send the project ID when fetching a simulation run
GetSimulationRun accepts an API key or a session token, and the session path rejects the request when project_id is absent. Every caller already has the resolved project, so pass it through.
1 parent c32b4e8 commit 53f6847

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎cmd/lk/simulate.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,13 @@ func uploadSource(ctx context.Context, client *lksdk.AgentSimulationClient, runI
550550
return nil
551551
}
552552

553-
func getSimulationRun(ctx context.Context, client *lksdk.AgentSimulationClient, runID string) (*livekit.SimulationRun, error) {
553+
// getSimulationRun carries the project ID because the server accepts either an
554+
// API key or a session token, and the session path cannot resolve the run
555+
// without it.
556+
func getSimulationRun(ctx context.Context, client *lksdk.AgentSimulationClient, runID, projectID string) (*livekit.SimulationRun, error) {
554557
resp, err := client.GetSimulationRun(ctx, &livekit.SimulationRun_Get_Request{
555558
SimulationRunId: runID,
559+
ProjectId: projectID,
556560
})
557561
if err != nil {
558562
return nil, err

‎cmd/lk/simulate_ci.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func runSimulateCI(ctx context.Context, config *simulateConfig) error {
146146

147147
for {
148148
pollCtx, pollCancel := context.WithTimeout(ctx, simulationAPITimeout)
149-
run, err = getSimulationRun(pollCtx, config.client, runID)
149+
run, err = getSimulationRun(pollCtx, config.client, runID, config.pc.ProjectId)
150150
pollCancel()
151151

152152
if err != nil {
@@ -254,7 +254,7 @@ func runSimulateCIView(ctx context.Context, config *simulateConfig) error {
254254
for {
255255
pollCtx, pollCancel := context.WithTimeout(ctx, simulationAPITimeout)
256256
var err error
257-
run, err = getSimulationRun(pollCtx, config.client, runID)
257+
run, err = getSimulationRun(pollCtx, config.client, runID, config.pc.ProjectId)
258258
pollCancel()
259259
if err != nil {
260260
if ctx.Err() != nil {

‎cmd/lk/simulate_tui.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ func (m *simulateModel) runSetup() tea.Cmd {
427427
if c.mode == modeView {
428428
ctx, cancel := context.WithTimeout(context.Background(), simulationAPITimeout)
429429
defer cancel()
430-
run, err := getSimulationRun(ctx, m.config.client, m.config.viewModeRunID)
430+
run, err := getSimulationRun(ctx, m.config.client, m.config.viewModeRunID, m.config.pc.ProjectId)
431431
if err != nil {
432432
m.err = err
433433
}
@@ -569,7 +569,7 @@ func (m *simulateModel) pollSimulation() tea.Cmd {
569569
return func() tea.Msg {
570570
ctx, cancel := context.WithTimeout(context.Background(), simulationAPITimeout)
571571
defer cancel()
572-
run, err := getSimulationRun(ctx, m.config.client, m.runID)
572+
run, err := getSimulationRun(ctx, m.config.client, m.runID, m.config.pc.ProjectId)
573573
return simulationRunMsg{run: run, err: err}
574574
}
575575
}

0 commit comments

Comments
 (0)