Skip to content

Fix fractional JSON size limits - #235

Open
codingkiddo wants to merge 1 commit into
Netflix:mainfrom
codingkiddo:fix/json-size-fractional-limits
Open

Fix fractional JSON size limits#235
codingkiddo wants to merge 1 commit into
Netflix:mainfrom
codingkiddo:fix/json-size-fractional-limits

Conversation

@codingkiddo

Copy link
Copy Markdown

Summary

Fix fractional size handling in JsonSizeConstraint.

The existing implementation rounds the numeric value before converting KB, MB, or GB values to bytes. As a result, fractional limits such as 0.5KB are interpreted incorrectly.

For example:

  • Expected: 0.5KB = 512 bytes
  • Previous behavior: round(0.5) * 1024 = 1024 bytes

Changes

  • Preserve the fractional value until after conversion to bytes.
  • Round the final byte count instead of the original numeric value.
  • Add a regression test covering a 0.5KB limit.
  • Correct the JsonSizeConstraint Javadoc examples to use quoted string values.

Testing

Ran:

./gradlew :maestro-common:test \
  --tests com.netflix.maestro.validations.JsonSizeConstraintTest

and:

./gradlew :maestro-common:check

Signed-off-by: Vinod Kumar <codingkiddo@gmail.com>
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

Successfully merging this pull request may close these issues.

1 participant