Skip to content

fix(schemas): keep stored Decimals when validating Dynamo documents - #274

Draft
khvn26 wants to merge 2 commits into
mainfrom
fix/schemas-stored-decimal-round-trip
Draft

khvn26 wants to merge 2 commits into
mainfrom
fix/schemas-stored-decimal-round-trip

Conversation

@khvn26

@khvn26 khvn26 commented Sep 26, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

DynamoDB reads numbers back as Decimals, and validating a document read from DynamoDB changes them:

  • An integer feature state value, e.g. Decimal("5"), becomes "5".
  • An integer trait value, e.g. Decimal("1"), becomes Decimal("1.0"), as DynamoInt | DynamoFloat picks the float member.

In this PR, we keep stored Decimals as they are:

  • DynamoInt and DynamoFloat accept a stored Decimal as is, and DynamoInt only an integral one.
  • validate_dynamo_feature_state_value keeps an integral Decimal.

Validating Python values or JSON is unchanged, as is the JSON schema.

How did you test this code?

Added tests for stored Decimals, and for validating each stored document twice. They fail without the fix.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.66%. Comparing base (0196ebd) to head (8aa120b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #274      +/-   ##
==========================================
+ Coverage   97.64%   97.66%   +0.01%     
==========================================
  Files         110      110              
  Lines        4919     4959      +40     
==========================================
+ Hits         4803     4843      +40     
  Misses        116      116              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants