Skip to content

strip whitespace from comma-separated service names#205

Open
AnshulPatil2005 wants to merge 1 commit intosugar-org:mainfrom
AnshulPatil2005:servicespace
Open

strip whitespace from comma-separated service names#205
AnshulPatil2005 wants to merge 1 commit intosugar-org:mainfrom
AnshulPatil2005:servicespace

Conversation

@AnshulPatil2005
Copy link

@AnshulPatil2005 AnshulPatil2005 commented Feb 17, 2026

Pull Request description

Fixes a bug where passing service names with spaces after commas (e.g. --services "service1, service2") would silently fail to match services. The space was being included as part of the service name, causing mismatches.

Root cause: _arg_services.split(',') in _get_services_names did not strip whitespace from each element.
Fix: Changed to [s.strip() for s in _arg_services.split(',')] in src/sugar/extensions/base.py.

solve #204

How to test these changes

run test

  • pytest tests/test_ext_compose.py::test_cmd_build_services_with_spaces

Pull Request checklists

This PR is a:

  • bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

  • I have reviewed the changes and it contains no misspelling.
  • The code is well commented, especially in the parts that contain more
    complexity.
  • New and old tests passed locally.

Additional information

Before fix: "service1, service2".split(',')['service1', ' service2'] — the leading space on service2 causes a lookup failure.

After fix: [s.strip() for s in "service1, service2".split(',')]['service1', 'service2'] — correct.

Changed file: src/sugar/extensions/base.py line 436.
Test added: tests/test_ext_compose.py::test_cmd_build_services_with_spaces.

@AnshulPatil2005
Copy link
Author

AnshulPatil2005 commented Feb 19, 2026

@sanjay7178 @xmnlab Could you please review this PR when you get a chance.

Thanks.

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.

1 participant