Fix computer use session error status

This commit is contained in:
Simos Mikelatos
2026-06-19 07:47:56 +00:00
parent 25ab273b05
commit 9f24f80f33
13 changed files with 41 additions and 9 deletions

View File

@@ -14,13 +14,13 @@ jobs:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22
cache: npm
@@ -73,7 +73,7 @@ jobs:
cat release/SHASUMS256.txt
- name: Upload branch build artifacts
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: ${{ steps.artifact.outputs.name }}
path: |

View File

@@ -17,7 +17,11 @@ function encryptSecret(secret) {
function decryptSecret(record) {
if (!record?.value) return null;
if (!record.encrypted) return record.value;
return safeStorage.decryptString(Buffer.from(record.value, 'base64'));
try {
return safeStorage.decryptString(Buffer.from(record.value, 'base64'));
} catch {
return null;
}
}
export class CloudController {

View File

@@ -1,6 +1,7 @@
import express from 'express';
import { computerUseService } from '@/modules/computer-use/computer-use.service.js';
import { AppError } from '@/shared/utils.js';
const router = express.Router();
@@ -12,12 +13,30 @@ type AuthenticatedRequest = express.Request & {
function requireUser(req: AuthenticatedRequest): { id: string | number } {
const userId = req.user?.id;
if (userId === undefined || userId === null) {
throw new Error('Authenticated user is required.');
if (userId === undefined || userId === null || String(userId).trim() === '') {
throw new AppError('Authenticated user is required.', {
code: 'AUTHENTICATED_USER_REQUIRED',
statusCode: 401,
});
}
return { id: userId };
}
function getErrorStatusCode(error: unknown, fallbackStatusCode: number): number {
if (error instanceof AppError) {
return error.statusCode;
}
if (error && typeof error === 'object') {
const statusCode = 'statusCode' in error ? error.statusCode : 'status' in error ? error.status : undefined;
if (typeof statusCode === 'number' && Number.isInteger(statusCode) && statusCode >= 400 && statusCode <= 599) {
return statusCode;
}
}
return fallbackStatusCode;
}
function readParam(value: string | string[] | undefined): string {
return Array.isArray(value) ? value[0] || '' : value || '';
}
@@ -92,7 +111,7 @@ router.get('/sessions', async (req: AuthenticatedRequest, res) => {
try {
res.json({ success: true, data: { sessions: await computerUseService.listSessions(requireUser(req)) } });
} catch (error) {
res.status(401).json({
res.status(getErrorStatusCode(error, 500)).json({
success: false,
error: error instanceof Error ? error.message : 'Failed to list Computer Use sessions.',
});

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API & Token",
"tasks": "Aufgaben",
"computer": "Computer Use",
"notifications": "Benachrichtigungen",
"plugins": "Plugins",
"about": "Info"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API & Tokens",
"tasks": "Tâches",
"computer": "Computer Use",
"notifications": "Notifications",
"plugins": "Plugins",
"about": "À propos"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API e Token",
"tasks": "Attività",
"computer": "Computer Use",
"notifications": "Notifiche",
"plugins": "Plugin",
"about": "Informazioni"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API & トークン",
"tasks": "タスク",
"computer": "Computer Use",
"notifications": "通知",
"plugins": "プラグイン",
"about": "概要"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API & 토큰",
"tasks": "작업",
"computer": "Computer Use",
"notifications": "알림",
"plugins": "플러그인",
"about": "정보"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API и токены",
"tasks": "Задачи",
"computer": "Computer Use",
"notifications": "Уведомления",
"plugins": "Плагины",
"about": "О программе"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API ve Token'lar",
"tasks": "Görevler",
"computer": "Computer Use",
"notifications": "Bildirimler",
"plugins": "Eklentiler",
"about": "Hakkında"

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API 和令牌",
"tasks": "任务",
"computer": "Computer Use",
"notifications": "通知",
"plugins": "插件",
"about": "关于"

View File

@@ -23,8 +23,8 @@
"files": "檔案",
"git": "版本控制",
"tasks": "任務",
"browser": "Browser",
"computer": "Computer"
"browser": "瀏覽器",
"computer": "電腦"
},
"status": {
"loading": "載入中...",

View File

@@ -94,6 +94,7 @@
"git": "Git",
"apiTokens": "API 和權杖",
"tasks": "任務",
"computer": "Computer Use",
"notifications": "通知",
"plugins": "外掛",
"about": "關於"