Skip to content

Conversation

rbiamru
Copy link

@rbiamru rbiamru commented Sep 4, 2025

Fixes #1699

What was happening

Group names were treated as case-sensitive on Linux. This allowed creating both default and defAult as separate groups, even though groups were intended to be case-insensitive.

What I changed

  • Added validation to enforce lowercase-only group names in manager.go (Create, Get, Delete, Exists).
  • Group names with uppercase characters are now rejected with a clear error.
Error: invalid group name: "MyGroup" (must be lowercase)
  • Updated unit tests in group_test.go:
  • Folded invalid-name tests into TestManager_Create (uppercase + mixed-case).
  • Verified that duplicates with different casing are rejected at validation.
  • Kept "success" and "already exists" cases intact.

How I tested

  • Built and ran locally on Windows with Docker (nginx workload).
  • Manual CLI tests:
    • ./thv group create MyGroup → error
    • ./thv run --group MyGroup docker.io/library/nginx:latest → error
    • ./thv group create mygroup → success
Screenshot 2025-09-04 102242 - Creating `defAult` since default.json already present in Local/toolhive/groups Screenshot 2025-09-04 104234
  • Unit tests pass:
Screenshot 2025-09-04 100917

Copy link
Contributor

@blkt blkt left a comment

Choose a reason for hiding this comment

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

Hi @rbiamru thank you for your contribution. I left a small comment about the resulting UX, let's see what other folks think.

Comment on lines 37 to 38
// Lowercase the group name before checking for existence
name = strings.ToLower(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: I don't think this is the right way of fixing this problem.

The way this is implemented, the user would think that he/she was able to create a group named MyGroup with a mix of uppercase and lowercase letters, while that's not the case. Since this is a user defined property and the user will refer to it from the CLI, it might be better to ensure that name == strings.ToLower(name) and return a specific error when that's not the case.

Note that this would apply to all routines, not just Create.

@amirejaz what do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree @blkt , enforcing lowercase with a clear error across all routines makes sense.

Copy link
Author

@rbiamru rbiamru Sep 4, 2025

Choose a reason for hiding this comment

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

Thanks for the feedback! I updated the implementation to enforce lowercase validation (no normalization) and updated tests to assert errors for uppercase & mixed-case names. Verified group create / run --group. Both CLI and unit tests now pass.

/cc @blkt @amirejaz

Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 33.43%. Comparing base (0b47fde) to head (2e35eb6).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1711      +/-   ##
==========================================
+ Coverage   33.42%   33.43%   +0.01%     
==========================================
  Files         216      216              
  Lines       26716    26721       +5     
==========================================
+ Hits         8929     8934       +5     
  Misses      17138    17138              
  Partials      649      649              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 35.744% (+0.01%) from 35.733%
when pulling 2e35eb6 on rbiamru:fix-group-case-insensitive
into 0b47fde on stacklok:main.

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.

Group name is case-sensitive on Linux
4 participants