Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Nov 7, 2025

Pull Request description:


Fix ANSI Escape Code Pollution - Environment-Aware bcolors

Summary

This PR fixes Issue #2592 by making the existing bcolors class environment-aware, ensuring that ANSI escape codes do not pollute ROS logs while maintaining backward compatibility.

Changes Made

  • Made the bcolors class respect the RCUTILS_COLORIZED_OUTPUT environment variable.

  • Automatically detect whether output is a TTY to enable/disable colors intelligently.

  • Removed all ANSI codes from logger calls in:

    • controller_manager_services.py

    • spawner.py

    • hardware_spawner.py

  • Retained bcolors usage across the codebase to avoid breaking existing behavior.

Environment Variable Behavior

Variable Behavior
RCUTILS_COLORIZED_OUTPUT=0 No colors in output
RCUTILS_COLORIZED_OUTPUT=1 Colors enabled
Unset Auto-detects TTY and enables colors only if supported

Testing and Verification

  • Verified that logs are now clean and contain no escape codes.

  • Confirmed that CLI output remains colorized when applicable.

  • Verified backward compatibility with existing code paths.

  • Ran pre-commit checks (Python hooks passed;

Checklist

  • Limited scope: focuses solely on Issue Option for uncolored log output #2592

  • Descriptive commit message and PR title

  • CI expected to pass

  • Logger outputs verified to be ANSI-free

  • Manual tests confirm correct color behavior

Contributing Notes

Before submitting PRs:

  1. Keep PRs focused on a single issue or feature.

  2. Use clear, descriptive titles and concise summaries.

  3. Ensure the CI pipeline passes.

  4. Request reviews from maintainers when ready.

  5. Add or update tests where applicable.



This is an automatic backport of pull request #2741 done by [Mergify](https://mergify.com).

(cherry picked from commit 38110f4)

# Conflicts:
#	doc/release_notes.rst
@mergify mergify bot added the conflicts label Nov 7, 2025
@mergify
Copy link
Contributor Author

mergify bot commented Nov 7, 2025

Cherry-pick of 38110f4 has failed:

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

You are currently cherry-picking commit 38110f4.
  (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:
	modified:   controller_manager/controller_manager/controller_manager_services.py
	modified:   controller_manager/controller_manager/hardware_spawner.py
	modified:   controller_manager/controller_manager/spawner.py
	modified:   controller_manager/doc/userdoc.rst

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   doc/release_notes.rst

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

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.54%. Comparing base (563d40a) to head (e20fb5e).
⚠️ Report is 1 commits behind head on kilted.

Files with missing lines Patch % Lines
.../controller_manager/controller_manager_services.py 77.77% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           kilted    #2784      +/-   ##
==========================================
- Coverage   89.55%   89.54%   -0.02%     
==========================================
  Files         152      152              
  Lines       17719    17728       +9     
  Branches     1454     1456       +2     
==========================================
+ Hits        15869    15874       +5     
- Misses       1264     1266       +2     
- Partials      586      588       +2     
Flag Coverage Δ
unittests 89.54% <80.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ler_manager/controller_manager/hardware_spawner.py 70.23% <100.00%> (ø)
controller_manager/controller_manager/spawner.py 71.51% <100.00%> (ø)
.../controller_manager/controller_manager_services.py 81.14% <77.77%> (-1.39%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@christophfroehlich christophfroehlich merged commit b17f596 into kilted Nov 7, 2025
13 of 15 checks passed
@christophfroehlich christophfroehlich deleted the mergify/bp/kilted/pr-2741 branch November 7, 2025 09:59
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.

3 participants