Skip to content

Misleading: Missing Input Validation in /encode endpoint #10

@rohan-pandeyy

Description

@rohan-pandeyy

Describe the bug

The /encode endpoint (both GET and POST) does not validate if latitude and longitude are provided. If they are missing, the internal logic throws a TypeError due to undefined arithmetic, which is caught and returned as a 400 error with a confusing message: Cannot read properties of undefined (reading 'NaN').

Steps to reproduce

  1. Send a POST request to /digipin/encode with an empty body {}.
  2. Observe the response.

Expected behavior

The API should explicitly check for missing parameters and return a clear error message like Latitude and Longitude are required.

Actual behavior

Returns {"error": "Cannot read properties of undefined (reading 'NaN')"}.

Screenshot

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions