Skip to content

refactor: Add status field validation at DTO level #227

@Xhristin3

Description

@Xhristin3

Problem Statement

The UpdateStreamDto.status field (api/src/streams/dto/update-stream.dto.ts:24) accepts any 1-50 character string. While the service layer validates transitions, the DTO should also enforce valid status values for defense-in-depth.

Evidence

@IsOptional()
@IsString()
@Length(1, 50, { message: "status must be between 1 and 50 characters" })
status?: string   // accepts any string, not just valid states

Impact

API accepts arbitrary status strings. The service rejects them later with ConflictException, but the API contract should be narrow. Swagger documentation auto-generates an open-ended status field.

Proposed Solution

Add @IsIn(['inactive', 'active', 'error']) validator to the status field, matching the ListStreamsQueryDto.status pattern.

Acceptance Criteria

  • PATCH /streams/:id with status="unknown" returns 400 validation error
  • PATCH /streams/:id with status="active" passes DTO validation
  • Swagger docs show enum for status field

File Map

  • api/src/streams/dto/update-stream.dto.ts — add @isin()

Labels: refactoring, good first issue
Priority: Low | Difficulty: Beginner | Estimated Effort: 0.5h


Labels: refactoring,good first issue
Priority: Low | Difficulty: Beginner | Estimated Effort: 0.5h
Backlog ID: REPO-044

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions