Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce Boolean Query Parameters Using Joi Transformations #2272

Open
6 of 10 tasks
VinuB-Dev opened this issue Nov 29, 2024 · 0 comments
Open
6 of 10 tasks

Enforce Boolean Query Parameters Using Joi Transformations #2272

VinuB-Dev opened this issue Nov 29, 2024 · 0 comments

Comments

@VinuB-Dev
Copy link
Contributor

Issue Description

Currently, query parameters intended to represent boolean values (e.g., departed=true, dev=true) are treated as strings instead of being parsed as actual booleans. This limitation arises because the backend does not support query parameter transformations to boolean types. For instance, the dev flag is defined as joi.string() instead of joi.boolean() in the validation layer, causing boolean-like inputs to remain as strings.

This behavior leads to inconsistent handling of boolean parameters and increases the risk of errors in processing such values. Supporting actual boolean parsing for query parameters will require transformations in the backend to convert "true"/"false" strings to their respective boolean values.

While this is not a critical issue, it is better addressed as an enhancement task to align with expected behaviors.

Expected Behavior

The API should accept query parameters as proper booleans instead of strings ("true" or "false") for flags like departed and dev. The backend should automatically transform and validate these parameters using joi.boolean().

Current Behavior

Currently, query parameters intended to be booleans (e.g., departed, dev) are handled as strings ("true" or "false"). There is no native boolean support in query parameters, and the transformation to actual booleans is not implemented.

Screenshots

Current validation schema showing the dev flag and profile param handled as a string instead of a boolean.

Image

Reproducibility

  • This issue is reproducible
  • This issue is not reproducible

Steps to Reproduce

  1. Pass a boolean query parameter (departed=true) to the API.
  2. Observe that it is treated as a string instead of a boolean.

Severity/Priority

  • Critical
  • High
  • Medium
  • Low

Additional Information

  • The current implementation uses Joi validation but does not enforce joi.boolean() transformations for query parameters.
  • This enhancement would require backend updates to handle the conversion seamlessly and consistently across all endpoints.
  • It also aligns with improving type safety and API usability.

Checklist

  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand and reproduce the issue.
  • I am willing to contribute to the resolution of this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant