Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion apps/server/src/routes/sessions/routes/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getErrorMessage, logError } from '../common.js';
export function createArchiveHandler(agentService: AgentService) {
return async (req: Request, res: Response): Promise<void> => {
try {
const { sessionId } = req.params;
const sessionId = req.params.sessionId as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a type assertion with as string bypasses TypeScript's type safety and can hide runtime errors if req.params.sessionId is not a string (e.g., undefined or string[]). A runtime check is a more robust approach. This ensures the input is validated and invalid requests are handled gracefully with a 400 Bad Request response.

      const sessionId = req.params.sessionId;
      if (typeof sessionId !== 'string') {
        res.status(400).json({ success: false, error: 'Invalid sessionId parameter' });
        return;
      }

const success = await agentService.archiveSession(sessionId);

if (!success) {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/sessions/routes/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getErrorMessage, logError } from '../common.js';
export function createDeleteHandler(agentService: AgentService) {
return async (req: Request, res: Response): Promise<void> => {
try {
const { sessionId } = req.params;
const sessionId = req.params.sessionId as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a type assertion with as string bypasses TypeScript's type safety and can hide runtime errors if req.params.sessionId is not a string (e.g., undefined or string[]). A runtime check is a more robust approach. This ensures the input is validated and invalid requests are handled gracefully with a 400 Bad Request response.

      const sessionId = req.params.sessionId;
      if (typeof sessionId !== 'string') {
        res.status(400).json({ success: false, error: 'Invalid sessionId parameter' });
        return;
      }

const success = await agentService.deleteSession(sessionId);

if (!success) {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/sessions/routes/unarchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getErrorMessage, logError } from '../common.js';
export function createUnarchiveHandler(agentService: AgentService) {
return async (req: Request, res: Response): Promise<void> => {
try {
const { sessionId } = req.params;
const sessionId = req.params.sessionId as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a type assertion with as string bypasses TypeScript's type safety and can hide runtime errors if req.params.sessionId is not a string (e.g., undefined or string[]). A runtime check is a more robust approach. This ensures the input is validated and invalid requests are handled gracefully with a 400 Bad Request response.

      const sessionId = req.params.sessionId;
      if (typeof sessionId !== 'string') {
        res.status(400).json({ success: false, error: 'Invalid sessionId parameter' });
        return;
      }

const success = await agentService.unarchiveSession(sessionId);

if (!success) {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/sessions/routes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getErrorMessage, logError } from '../common.js';
export function createUpdateHandler(agentService: AgentService) {
return async (req: Request, res: Response): Promise<void> => {
try {
const { sessionId } = req.params;
const sessionId = req.params.sessionId as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a type assertion with as string bypasses TypeScript's type safety and can hide runtime errors if req.params.sessionId is not a string (e.g., undefined or string[]). A runtime check is a more robust approach. This ensures the input is validated and invalid requests are handled gracefully with a 400 Bad Request response.

      const sessionId = req.params.sessionId;
      if (typeof sessionId !== 'string') {
        res.status(400).json({ success: false, error: 'Invalid sessionId parameter' });
        return;
      }

const { name, tags, model } = req.body as {
name?: string;
tags?: string[];
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/terminal/routes/session-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getTerminalService } from '../../../services/terminal-service.js';
export function createSessionDeleteHandler() {
return (req: Request, res: Response): void => {
const terminalService = getTerminalService();
const { id } = req.params;
const id = req.params.id as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a type assertion with as string bypasses TypeScript's type safety and can hide runtime errors if req.params.id is not a string (e.g., undefined or string[]). A runtime check is a more robust approach. This ensures the input is validated and invalid requests are handled gracefully with a 400 Bad Request response.

    const id = req.params.id;
    if (typeof id !== 'string') {
      res.status(400).json({ success: false, error: 'Invalid id parameter' });
      return;
    }

const killed = terminalService.killSession(id);

if (!killed) {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/routes/terminal/routes/session-resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getTerminalService } from '../../../services/terminal-service.js';
export function createSessionResizeHandler() {
return (req: Request, res: Response): void => {
const terminalService = getTerminalService();
const { id } = req.params;
const id = req.params.id as string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a type assertion with as string bypasses TypeScript's type safety and can hide runtime errors if req.params.id is not a string (e.g., undefined or string[]). A runtime check is a more robust approach. This ensures the input is validated and invalid requests are handled gracefully with a 400 Bad Request response.

    const id = req.params.id;
    if (typeof id !== 'string') {
      res.status(400).json({ success: false, error: 'Invalid id parameter' });
      return;
    }

const { cols, rows } = req.body;

if (!cols || !rows) {
Expand Down