( ctx context.Context, workspaceRef string, sessionID string, )
| 2099 | } |
| 2100 | |
| 2101 | func (h *HostAPIHandler) requireHostAPISessionWorkspace( |
| 2102 | ctx context.Context, |
| 2103 | workspaceRef string, |
| 2104 | sessionID string, |
| 2105 | ) (*session.Info, error) { |
| 2106 | if h.sessions == nil { |
| 2107 | return nil, errors.New("extension: session manager is not configured") |
| 2108 | } |
| 2109 | id := strings.TrimSpace(sessionID) |
| 2110 | if id == "" { |
| 2111 | return nil, invalidParamsRPCError(errors.New("session_id is required")) |
| 2112 | } |
| 2113 | workspaceID, err := h.resolveRequiredWorkspaceID(ctx, workspaceRef) |
| 2114 | if err != nil { |
| 2115 | return nil, err |
| 2116 | } |
| 2117 | info, err := h.sessions.Status(ctx, id) |
| 2118 | if err != nil { |
| 2119 | if errors.Is(err, session.ErrSessionNotFound) { |
| 2120 | return nil, notFoundRPCError("session", id, err) |
| 2121 | } |
| 2122 | return nil, err |
| 2123 | } |
| 2124 | if info == nil || strings.TrimSpace(info.WorkspaceID) != workspaceID { |
| 2125 | return nil, notFoundRPCError( |
| 2126 | "session", |
| 2127 | id, |
| 2128 | fmt.Errorf("%w: session=%q workspace_id=%q", session.ErrSessionNotFound, id, workspaceID), |
| 2129 | ) |
| 2130 | } |
| 2131 | return info, nil |
| 2132 | } |
| 2133 | |
| 2134 | func (h *HostAPIHandler) automationManager() (HostAPIAutomationManager, error) { |
| 2135 | if h == nil { |
no test coverage detected