8000 fix: add workspace owner id as query param to websocket by jaaydenh · Pull Request #18363 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

fix: add workspace owner id as query param to websocket #18363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fmt
  • Loading branch information
Emyrk committed Jun 13, 2025
commit ed17eaf7038a9c2da2c2826aec6cd3f05d3ccda1
3 changes: 2 additions & 1 deletion codersdk/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/google/uuid"
"golang.org/x/xerrors"

"github.com/coder/coder/v2/codersdk/wsjson"
"github.com/coder/websocket"
Expand Down Expand Up @@ -130,7 +131,7 @@ func (c *Client) TemplateVersionDynamicParameters(ctx context.Context, userID st
if userID != Me {
uid, err := uuid.Parse(userID)
if err != nil {
return nil, fmt.Errorf("invalid user ID: %w", err)
return nil, xerrors.Errorf("invalid user ID: %w", err)
}
endpoint += fmt.Sprintf("?user_id=%s", uid.String())
}
Expand Down
3 changes: 2 additions & 1 deletion site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,8 @@ class ApiMethods {
},
): WebSocket => {
const socket = createWebSocket(
`/api/v2/templateversions/${versionId}/dynamic-parameters?user_id=${userId}`,
`/api/v2/templateversions/${versionId}/dynamic-parameters`,
new URLSearchParams({ user_id: userId }),
);

socket.addEventListener("message", (event) =>
Expand Down
< 7BAE td class="blob-num blob-num-addition empty-cell">
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,28 @@ const CreateWorkspacePageExperimental: FC = () => {
useEffect(() => {
if (!realizedVersionId) return;

const socket = API.templateVersionDynamicParameters(realizedVersionId, "me", {
onMessage,
onError: (error) => {
if (ws.current === socket) {
setWsError(error);
}
},
onClose: () => {
if (ws.current === socket) {
setWsError(
new DetailedError(
"Websocket connection for dynamic parameters unexpectedly closed.",
"Refresh the page to reset the form.",
),
);
}
const socket = API.templateVersionDynamicParameters(
realizedVersionId,
"me",
{
onMessage,
onError: (error) => {
if (ws.current === socket) {
setWsError(error);
}
},
onClose: () => {
if (ws.current === socket) {
setWsError(
new DetailedError(
"Websocket connection for dynamic parameters unexpectedly closed.",
"Refresh the page to reset the form.",
),
);
}
},
},
});
);

ws.current = socket;

Expand Down
Loading
0