Skip to content

Commit e90e098

Browse files
authored
Treat unrecognized ROS_DISTRO as a future distro (#1485)
Previously, `getDistroId()` returned `UNKNOWN (0)` for any `ROS_DISTRO` value not in the known map. This caused forward-looking feature guards (e.g., `>= ROLLING`) to fail for future distros like "lyrical", even though they would include the same ABI changes as Rolling. Now, if `ROS_DISTRO` is set but not recognized, `getDistroId()` returns `FUTURE (9999)` instead, so feature guards pass correctly. If `ROS_DISTRO` is unset, it still returns `UNKNOWN (0)`. ### Changes - **lib/distro.js** - Added `FUTURE: 9999` to `DistroId` enum - Updated `getDistroId()` to return `FUTURE` when `ROS_DISTRO` is set but not in the known map, `UNKNOWN` when unset - **test/test-distro.js** - Updated "unknown distro" test to expect `FUTURE` for unrecognized `ROS_DISTRO` values - Added assertion for truly unset `ROS_DISTRO` returning `UNKNOWN` Fix: #1484
1 parent 1af7e77 commit e90e098

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

.github/workflows/linux-x64-build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
# Install any remaining runtime dependencies using rosdep
8181
rosdep init || true
8282
rosdep update
83-
rosdep install --rosdistro rolling --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 urdfdom_headers python3-pyqt6.qtsvg rosidl_buffer_py pybind11"
83+
rosdep install --rosdistro rolling --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 rti-connext-dds-7.7.0 urdfdom_headers python3-pyqt6.qtsvg rosidl_buffer_py pybind11"
8484
8585
- name: Install test-msgs and mrpt_msgs on Linux
8686
if: ${{ matrix.ros_distribution != 'rolling' }}

lib/distro.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const DistroId = {
2727
JAZZY: 2405,
2828
KILTED: 2505,
2929
ROLLING: 5000,
30+
FUTURE: 9999, // unrecognized ROS_DISTRO assumed newer than Rolling
3031
};
3132

3233
const DistroNameIdMap = new Map();
@@ -48,11 +49,15 @@ const DistroUtils = {
4849
* @return {number} Return the rclnodejs distro identifier
4950
*/
5051
getDistroId: function (distroName) {
51-
const dname = distroName ? distroName.toLowerCase() : this.getDistroName();
52+
const dname =
53+
(distroName || this.getDistroName() || '').toLowerCase() || undefined;
5254

53-
return DistroNameIdMap.has(dname)
54-
? DistroNameIdMap.get(dname)
55-
: DistroId.UNKNOWN;
55+
if (dname && DistroNameIdMap.has(dname)) {
56+
return DistroNameIdMap.get(dname);
57+
}
58+
59+
// Unrecognized but provided/resolved distro name → assume future; unset → unknown
60+
return dname ? DistroId.FUTURE : DistroId.UNKNOWN;
5661
},
5762

5863
/**

test/test-distro.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,29 @@ describe('rclnodejs distro utils', function () {
6060
it('unknown distro', function (done) {
6161
let backupEnvar = process.env.ROS_DISTRO;
6262

63-
// test unknown distro
63+
// test unknown distro — when ROS_DISTRO is set but unrecognized,
64+
// assume it is a future distro (newer than Rolling)
6465
process.env.ROS_DISTRO = 'xxx';
6566
assert.equal(
6667
'xxx',
6768
DistroUtils.getDistroName(),
6869
`Failed unknown distro name`
6970
);
7071
let id = DistroUtils.getDistroId();
71-
assert.equal(id, DistroUtils.DistroId.UNKNOWN);
72+
assert.equal(id, DistroUtils.DistroId.FUTURE);
7273
assert.equal(
73-
DistroUtils.DistroId.UNKNOWN,
74+
DistroUtils.DistroId.FUTURE,
7475
DistroUtils.getDistroId('xxx'),
7576
"getDistroId('xxx') failed"
7677
);
7778

78-
process.env.ROS_DISTRO = backupEnvar;
79+
// test truly unknown — ROS_DISTRO unset
80+
delete process.env.ROS_DISTRO;
81+
assert.equal(DistroUtils.getDistroId(), DistroUtils.DistroId.UNKNOWN);
82+
83+
if (backupEnvar !== undefined) {
84+
process.env.ROS_DISTRO = backupEnvar;
85+
}
7986
done();
8087
});
8188

0 commit comments

Comments
 (0)