Skip to content

Treat unrecognized ROS_DISTRO as a future distro#1485

Merged
minggangw merged 2 commits intoRobotWebTools:developfrom
minggangw:fix-1484
Apr 10, 2026
Merged

Treat unrecognized ROS_DISTRO as a future distro#1485
minggangw merged 2 commits intoRobotWebTools:developfrom
minggangw:fix-1484

Conversation

@minggangw
Copy link
Copy Markdown
Member

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

Copilot AI review requested due to automatic review settings April 10, 2026 05:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates ROS distro detection so that forward-compatible feature guards work when ROS_DISTRO contains a newer, unrecognized distro name by mapping it to a high sentinel ID (FUTURE) instead of UNKNOWN.

Changes:

  • Added FUTURE (9999) to the distro ID enum.
  • Updated getDistroId() to return FUTURE for unrecognized-but-present distro names while preserving UNKNOWN when ROS_DISTRO is unset.
  • Adjusted distro utility tests to validate the new FUTURE behavior and the unset-env behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/distro.js Introduces DistroId.FUTURE and changes getDistroId() fallback behavior for unrecognized distro names.
test/test-distro.js Updates the “unknown distro” test expectations and adds coverage for ROS_DISTRO being truly unset.

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

Comment on lines 51 to +59
getDistroId: function (distroName) {
const dname = distroName ? distroName.toLowerCase() : this.getDistroName();

return DistroNameIdMap.has(dname)
? DistroNameIdMap.get(dname)
: DistroId.UNKNOWN;
if (DistroNameIdMap.has(dname)) {
return DistroNameIdMap.get(dname);
}

// Unrecognized but set ROS_DISTRO → assume future distro; unset → unknown
return dname ? DistroId.FUTURE : DistroId.UNKNOWN;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

getDistroId() lowercases distroName when passed explicitly, but when it falls back to ROS_DISTRO it uses the raw environment value (see getDistroName() returning process.env.ROS_DISTRO). If ROS_DISTRO is set with different casing (e.g. Foxy), this will now be treated as FUTURE instead of matching a known distro. Consider normalizing the env value to lowercase inside getDistroId() (while still leaving getDistroName() to return the raw env string if you want that behavior).

Copilot uses AI. Check for mistakes.
lib/distro.js Outdated
return DistroNameIdMap.get(dname);
}

// Unrecognized but set ROS_DISTRO → assume future distro; unset → unknown
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The comment says this branch is for an "Unrecognized but set ROS_DISTRO", but the logic also applies when a caller passes an explicit distroName argument that isn’t in the map. Please update the comment (or the logic) so the behavior and documentation stay aligned.

Suggested change
// Unrecognized but set ROS_DISTRO → assume future distro; unset → unknown
// Unrecognized but provided/resolved distro name → assume future distro; unset → unknown

Copilot uses AI. Check for mistakes.
Comment on lines +79 to 84
// test truly unknown — ROS_DISTRO unset
delete process.env.ROS_DISTRO;
assert.equal(DistroUtils.getDistroId(), DistroUtils.DistroId.UNKNOWN);

process.env.ROS_DISTRO = backupEnvar;
done();
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Restoring process.env.ROS_DISTRO via process.env.ROS_DISTRO = backupEnvar; can be incorrect when the variable was originally unset: in Node, assigning undefined ends up setting the string 'undefined'. To avoid leaking state into later tests, restore by deleting the env var when backupEnvar is undefined (and only assign when it was originally set).

Copilot uses AI. Check for mistakes.
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 85.885% (+0.04%) from 85.844% — minggangw:fix-1484 into RobotWebTools:develop

@minggangw minggangw merged commit e90e098 into RobotWebTools:develop Apr 10, 2026
16 checks passed
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.

Treat unrecognized ROS_DISTRO as a future distro

3 participants