pydantic / pydantic-core

Core validation logic for pydantic written in rust
MIT License
1.4k stars 232 forks source link

Validate base64 standard encoding #1395

Closed josh-newman closed 1 month ago

josh-newman commented 1 month ago

Change Summary

Extends bytes base64 validation to accept standard encoding, in addition to the existing URL-safe.

I think a user providing base64 standard input is more likely to want successful (and unambiguous) decoding rather than a validation error. (Even while ser_json_bytes="base64" continues to emit the URL-safe variant.)

Related issue number

No issue, but this extends #1308: https://github.com/pydantic/pydantic-core/pull/1308#issuecomment-2143130478

Checklist

Selected Reviewer: @dmontagu

josh-newman commented 1 month ago

please review

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.61%. Comparing base (ab503cb) to head (f7170c5). Report is 139 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1395 +/- ## ========================================== - Coverage 90.21% 89.61% -0.60% ========================================== Files 106 109 +3 Lines 16339 17308 +969 Branches 36 41 +5 ========================================== + Hits 14740 15511 +771 - Misses 1592 1777 +185 - Partials 7 20 +13 ``` | [Files](https://app.codecov.io/gh/pydantic/pydantic-core/pull/1395?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) | Coverage Δ | | |---|---|---| | [src/validators/config.rs](https://app.codecov.io/gh/pydantic/pydantic-core/pull/1395?src=pr&el=tree&filepath=src%2Fvalidators%2Fconfig.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic#diff-c3JjL3ZhbGlkYXRvcnMvY29uZmlnLnJz) | `100.00% <100.00%> (ø)` | | ... and [39 files with indirect coverage changes](https://app.codecov.io/gh/pydantic/pydantic-core/pull/1395/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/pydantic/pydantic-core/pull/1395?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/pydantic/pydantic-core/pull/1395?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic). Last update [6e96b85...f7170c5](https://app.codecov.io/gh/pydantic/pydantic-core/pull/1395?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydantic).
codspeed-hq[bot] commented 1 month ago

CodSpeed Performance Report

Merging #1395 will not alter performance

Comparing d8e-ai:validate-base64-any (f7170c5) with main (6e96b85)

Summary

✅ 155 untouched benchmarks