Skip to content

Add base64 encoding and decoding functions with tests - #533

Merged
ahcorde merged 4 commits into
ros2:rollingfrom
Barry-Xu-2018:review/topic-support-encode-decode-base64
Feb 3, 2026
Merged

ahcorde merged 4 commits into
ros2:rollingfrom
Barry-Xu-2018:review/topic-support-encode-decode-base64

Conversation

@Barry-Xu-2018

Copy link
Copy Markdown
Contributor

Description

Add base64 encode and decode functionality. This is necessary when configuring binary data in YAML files.

The related issue is ros2/rcl#1256.

Is this user-facing behavior change?

No.

Did you use Generative AI?

Yes. The GitHub Copilot (Claude Sonnet 4.5) is used to generate code comments, some parts of the code, and test code.

Additional Information

Signed-off-by: Barry Xu <barry.xu@sony.com>
Copilot AI review requested due to automatic review settings January 30, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds base64 encoding and decoding functionality to rcutils, which is needed for handling binary data in YAML configuration files (as referenced in ros2/rcl#1256).

Changes:

  • Adds two new public functions: decode_base64 and encode_base64 for converting between binary data and base64-encoded strings
  • Includes comprehensive test coverage with valid/invalid input cases, edge cases, and round-trip testing
  • Updates CMakeLists.txt to include the new source file and test

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
include/rcutils/base64.h Defines the public API for base64 encoding/decoding functions with documentation
src/base64.c Implements the base64 encoding and decoding algorithms with error handling
test/test_base64.cpp Provides comprehensive test coverage including valid inputs, error cases, and round-trip tests
CMakeLists.txt Adds base64.c to the build and registers the test suite

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/rcutils/base64.h Resolved
Comment thread src/base64.c Resolved
Comment thread include/rcutils/base64.h Resolved
Comment thread include/rcutils/base64.h Resolved
Comment thread include/rcutils/base64.h Resolved
Comment thread src/base64.c Resolved
Comment thread include/rcutils/base64.h Resolved
Comment thread src/base64.c Resolved
Signed-off-by: Barry Xu <barry.xu@sony.com>
Comment thread CMakeLists.txt Resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde

ahcorde commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Pulls: #533
Gist: https://gist.githubusercontent.com/ahcorde/afbbac17f63a3ca58f9ad7f090b3c834/raw/86e6e577f0405d95df24a0618dba1b16b833379a/ros2.repos
BUILD args: --packages-above-and-dependencies rcutils
TEST args: --packages-above rcutils
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18092

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@Barry-Xu-2018

Copy link
Copy Markdown
Contributor Author

The failure of Linux/Linux-rhel was due to an internal CI issue and needs to be re-executed.
The failure of Windows is

C:\ci\ws\src\Barry-Xu-2018\rcutils\src\base64.c(20,1): fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory [C:\ci\ws\build\rcutils\rcutils.vcxproj]

I will fix it.

Signed-off-by: Barry Xu <barry.xu@sony.com>
@Barry-Xu-2018

Barry-Xu-2018 commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Due to code changes, I re-run all the tests.
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18105

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde
ahcorde merged commit f322436 into ros2:rolling Feb 3, 2026
3 checks passed
@ahcorde

ahcorde commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

https://github.com/Mergifyio backport kilted jazzy humble

@mergify

mergify Bot commented Feb 3, 2026 •

Copy link
Copy Markdown

backport kilted jazzy humble

✅ Backports have been created

Details

Cherry-pick of f322436 has failed:

On branch mergify/bp/humble/pr-533
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit f322436.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   include/rcutils/base64.h
	new file:   src/base64.c
	new file:   test/test_base64.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   CMakeLists.txt

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

mergify Bot pushed a commit that referenced this pull request Feb 3, 2026
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit f322436)
mergify Bot pushed a commit that referenced this pull request Feb 3, 2026
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit f322436)
mergify Bot pushed a commit that referenced this pull request Feb 3, 2026
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit f322436)

# Conflicts:
#	CMakeLists.txt

@fujitatomoya fujitatomoya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde i was doing review this, but one step behind... lgtm.

@fujitatomoya

Copy link
Copy Markdown
Collaborator

@Barry-Xu-2018 @ahcorde do we need to backport this function to downstream? i do not think downstream does not need this function. if that is not going to be used, maybe we do not need to backport this? i think the question is that are we going to backport tag support to the downstream?

@ahcorde

ahcorde commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Feel free to close them, I thought we should backport this.

@fujitatomoya

Copy link
Copy Markdown
Collaborator

@Barry-Xu-2018 what do you think?

@Barry-Xu-2018

Copy link
Copy Markdown
Contributor Author

@fujitatomoya @ahcorde

Yes. I don't think it's necessary to port it to the already released versions. This change was added to provide new support for the YAML binary tag.

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.

4 participants