Uh oh!
There was an error while loading. Please reload this page.
GH-49614: [C++] Report an error instead of silent truncation in base64_decode on invalid input - #49660
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4670ec5 to
5c7db64CompareReranko05
commented
Apr 4, 2026
Thanks for the feedback. I’ve updated the implementation and tests.
All tests pass locally. Please let me know if any further adjustments are needed. |
5c7db64 to
8f053b7Compare
kou
left a comment
There was a problem hiding this comment.
Could you use arrow::Result<std::string> return type instead of using ARROW_LOG()?
kou
commented
Apr 5, 2026
FYI: You can run CI on your fork by enabling GitHub Actions on your fork. |
Reranko05
commented
Apr 5, 2026
Thanks for the suggestion @kou ! Just to clarify, would you prefer changing the existing base64_decode API to return arrow::Resultstd::string, or introducing a separate checked variant while keeping the current API unchanged? I want to make sure the approach aligns with existing usage and expectations. |
kou
commented
Apr 5, 2026
"changing the existing base64_decode API to return arrow::Resultstd::string". |
Reranko05
commented
Apr 5, 2026
@kou I checked the current usages of Updating to I can proceed with the API change and update the affected call sites accordingly. |
Reranko05
commented
Apr 7, 2026
Hi @kou, just following up on this. I can proceed with updating Happy to proceed based on your guidance. |
kou
commented
Apr 8, 2026
Oh, sorry. I forgot to reply this... Yes. Let's proceed with |
8f053b7 to
34a388cCompareReranko05
commented
Apr 8, 2026
Hi @kou, thanks for confirming! I’ve updated All tests are passing locally. Please let me know if you’d like any changes or adjustments. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
This PR addresses a correctness issue in Arrow’s C++ base64 decoder by ensuring malformed base64 input is detected instead of producing silently truncated/partial output.
Changes:
- Adds pre-validation for base64 input (length, padding placement, invalid characters) in
base64_decode. - Changes
base64_decodeAPI to returnarrow::Result<std::string>withStatus::Invalidon malformed input. - Adds unit tests covering valid/invalid decoding cases (and adjusts a couple of
ToCharsassertions).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| cpp/src/arrow/vendored/base64.cpp | Adds base64 input validation and switches decode to return errors instead of partial output. |
| cpp/src/arrow/util/base64.h | Updates public API signature of base64_decode to return Result<std::string>. |
| cpp/src/arrow/util/string_test.cc | Adds tests for base64 decode validity/error cases and tweaks ToChars expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
34a388c to
ed84348CompareHi @kou, I have addressed all review comments:
All tests pass locally. |
kou
commented
Apr 8, 2026
Could you enable GitHub Actions on your fork to run CI on your fork too? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
22e6c2c to
98e24deCompareReranko05
commented
Apr 13, 2026
Hi @kou, I have addressed the remaining feedback by using |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
kou
left a comment
There was a problem hiding this comment.
+1
@dmitry-chirkov-dremio Do you want to review this before we merge this?
Yes, give me 24h. |
dmitry-chirkov-dremio
left a comment
There was a problem hiding this comment.
Looks good to me however won't approve until conversations are resolved (including Copilot's comments). Leaving couple of comments of my own as well.
Good job, @Reranko05 - almost there.
cc @kou
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
98e24de to
3dddf70CompareReranko05
commented
Apr 13, 2026
Thank you @dmitry-chirkov-dremio, I've addressed all review comments and resolved outstanding threads. |
kou
commented
Apr 14, 2026
Thanks. I'll merge this. |
Uh oh!
There was an error while loading. Please reload this page.
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit d9aeaa1. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 5 possible false positives for unstable benchmarks that are known to sometimes produce them. |
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit d9aeaa1. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 5 possible false positives for unstable benchmarks that are known to sometimes produce them. |
… base64_decode on invalid input (apache#49660) ### Rationale for this change `arrow::util::base64_decode` previously allowed invalid input to be processed, which could result in silently truncated or incorrect output without signaling an error. This can lead to unintended data corruption. ### What changes are included in this PR? - Change `base64_decode` to return `arrow::Result<std::string>` instead of `std::string` - Add validation for: - invalid input length - invalid base64 characters - incorrect padding - Return an error (`Status::Invalid`) for invalid input instead of producing partial output - Update all call sites to handle `Result<std::string>` - Add unit tests covering valid and invalid inputs ### Are these changes tested? Yes. Unit tests have been added to verify: - valid decoding behavior - invalid input length - invalid characters - incorrect padding handling ### Are there any user-facing changes? - The API now returns `arrow::Result<std::string>` instead of `std::string` - Invalid base64 input now results in an error (`Status::Invalid`) instead of returning partial or incorrect output * GitHub Issue: apache#49614 Authored-by: Aaditya Srinivasan <aadityasri03@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Rationale for this change
arrow::util::base64_decodepreviously allowed invalid input to be processed, which could result in silently truncated or incorrect output without signaling an error. This can lead to unintended data corruption.What changes are included in this PR?
base64_decodeto returnarrow::Result<std::string>instead ofstd::stringStatus::Invalid) for invalid input instead of producing partial outputResult<std::string>Are these changes tested?
Yes. Unit tests have been added to verify:
Are there any user-facing changes?
arrow::Result<std::string>instead ofstd::stringStatus::Invalid) instead of returning partial or incorrect output