Skip to content

Add structured validation for upload API payload #28

@TrishaG189

Description

@TrishaG189

Problem

The /api/images/upload endpoint validates file type and size, but does not enforce format or structure constraints on request body fields such as deviceAddress, imageHash, or cameraId.

Invalid values (e.g., malformed Ethereum addresses or incorrect hash formats) can propagate to deeper layers like blockchain calls, resulting in unclear errors and harder debugging.


Proposed Solution

Introduce structured validation for request payload using a schema-based approach.

  • Validate Ethereum address format for deviceAddress
  • Validate hex format for imageHash
  • Limit length of cameraId
  • Reject malformed payloads early and clean up uploaded files

Impact

  • Prevents invalid data from reaching core logic
  • Improves clarity of error responses
  • Makes the upload flow more robust and easier to debug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions