remark-github icon indicating copy to clipboard operation
remark-github copied to clipboard

Support Enterprise Managed User in userGroup Regex

Open EvHaus opened this issue 5 months ago • 2 comments

Initial checklist

  • [x] I read the support docs
  • [x] I read the contributing guide
  • [x] I agree to follow the code of conduct
  • [x] I searched issues and discussions and couldn’t find anything or linked relevant results below
  • [x] I made sure the docs are up to date
  • [x] I included tests (or that’s not needed)

Description of changes

A GitHub Enterprise customer discovered a bug in our product today (that uses remark-github). Their code was crashing with:

Unexpected invalid `repository`, expected for example `user/project`

After a bunch of troubleshooting I discovered it's because their GitHub username has an _ (underscore) in it. Turns out although generally this is not allowed on GitHub, Enterprise Managed Users can have underscores (see official docs).

This PR updates the Regex to support this and adds a unit test to catch this edge case.

EvHaus avatar Aug 08 '25 22:08 EvHaus

Do you have an exact quote from the website you are basing this on? Or, an exact case of input? From quickly glancing over that (sorry, little time), it seems to say that one underscore is used:

On GitHub.com, GitHub also adds an underscore and your enterprise's shortcode to the end of each username.

Usernames, including underscore and short code, must not exceed 39 characters.

Sounds like perhaps something else is needed, allowing one underscore + shortcode and checking length with code, rather than just allowing arbitrary underscores except at the last character? 🤔

wooorm avatar Aug 14 '25 19:08 wooorm

Do you have an exact quote from the website you are basing this on?

Yup -- it's that one that you found: "On GitHub.com, GitHub also adds an underscore and your enterprise's shortcode to the end of each username.".

Or, an exact case of input?

The exact user id I ran into was k-archarya_zse where I think _zse is the GHC instance suffix.

Sounds like perhaps something else is needed, allowing one underscore + shortcode and checking length with code, rather than just allowing arbitrary underscores except at the last character? 🤔

Sure. I can revise the Regex to only check for a single instance.

EvHaus avatar Aug 14 '25 20:08 EvHaus