google / google/shoptimizer

[Type verification] What is the expectation if user's API call sent wrong type? Such as `adult = "A String False"`.

Open
#20 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
48
Forks
27
PR merge metrics
No merged PRs in 30d

Description

For example, if in here, user sent API call that `adult = "A String False"`

https://github.com/google/shoptimizer/blob/a9fff3ac203e39480dff7585fa37b999fbe7470e/shoptimizer_api/optimizers_builtin/adult_optimizer.py#L89

Then in here the UT will fail, as shoptimizer will send string "False" directly outside.
https://github.com/google/shoptimizer/blob/a9fff3ac203e39480dff7585fa37b999fbe7470e/shoptimizer_api/optimizers_builtin/adult_optimizer_test.py#L273

Because in Python3, `if not "any string" `its value will be `False` in `boolean`. Then this will cause all these two `if` being passed
1. Passed
https://github.com/google/shoptimizer/blob/a9fff3ac203e39480dff7585fa37b999fbe7470e/shoptimizer_api/optimizers_builtin/adult_optimizer.py#L92
2. Passed
https://github.com/google/shoptimizer/blob/a9fff3ac203e39480dff7585fa37b999fbe7470e/shoptimizer_api/optimizers_builtin/adult_optimizer.py#L101

Then shoptimizer don't think its adult field need to change or santinize.

Just ask, is this phenomenon within the expectation?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.