MCPcopy Index your code
hub / github.com/coder/coder / validateChatWorkspaceSelection

Method validateChatWorkspaceSelection

coderd/exp_chats.go:4387–4425  ·  view source on GitHub ↗
(
	ctx context.Context,
	r *http.Request,
	workspaceID *uuid.UUID,
)

Source from the content-addressed store, hash-verified

4385}
4386
4387func (api *API) validateChatWorkspaceSelection(
4388 ctx context.Context,
4389 r *http.Request,
4390 workspaceID *uuid.UUID,
4391) (
4392 uuid.NullUUID,
4393 database.Workspace,
4394 int,
4395 *codersdk.Response,
4396) {
4397 if workspaceID == nil {
4398 return uuid.NullUUID{}, database.Workspace{}, 0, nil
4399 }
4400
4401 workspace, err := api.Database.GetWorkspaceByID(ctx, *workspaceID)
4402 if err != nil {
4403 if httpapi.Is404Error(err) {
4404 return uuid.NullUUID{}, database.Workspace{}, http.StatusBadRequest, &codersdk.Response{
4405 Message: "Workspace not found or you do not have access to this resource",
4406 }
4407 }
4408 return uuid.NullUUID{}, database.Workspace{}, http.StatusInternalServerError, &codersdk.Response{
4409 Message: "Failed to get workspace.",
4410 Detail: err.Error(),
4411 }
4412 }
4413
4414 selection := uuid.NullUUID{
4415 UUID: workspace.ID,
4416 Valid: true,
4417 }
4418 if !api.Authorize(r, policy.ActionSSH, workspace) {
4419 return uuid.NullUUID{}, database.Workspace{}, http.StatusBadRequest, &codersdk.Response{
4420 Message: "Workspace not found or you do not have access to this resource",
4421 }
4422 }
4423
4424 return selection, workspace, 0, nil
4425}
4426
4427func (api *API) validateCreateChatWorkspaceSelection(
4428 ctx context.Context,

Callers 2

patchChatMethod · 0.95

Calls 4

AuthorizeMethod · 0.95
Is404ErrorFunction · 0.92
GetWorkspaceByIDMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected