Harden GitHub handle extraction and verify account exists before inviting#9
Merged
Conversation
…ting
The "Add to GitHub org" shortcut parsed workflow request text by grabbing
the first whitespace-delimited token after the handle prompt. When an
applicant answered with a sentence ("My GitHub username is @Harshita-sriv.")
the bot extracted "My" — a valid-looking handle — and invited the real
GitHub user `my`.
Extraction now scans the whole answer line for an unambiguous signal (an
@mention or github.com URL token, or a lone token) and delegates stripping
and validation to normalise_github_username, refusing to guess on
multi-word prose. As a second safeguard, invite_and_greet now verifies the
account exists (GET /users/{username}) before any invite, so typo'd or
non-existent handles are rejected with a clear message.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
For you @jfy133 ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A GitHub invitation request came in where the applicant answered the handle question with a sentence:
The "Add to GitHub org" message shortcut parsed the answer by grabbing the first whitespace-delimited token after the prompt —
My— which is a valid-looking handle, so the bot invited the real GitHub usermyinstead of@Harshita-sriv.Changes
1. Smarter handle extraction (
add_member_shortcut.py)_handle_from_answernow scans the whole answer line for an unambiguous signal rather than blindly taking the first token:@mentiontoken →@Harshita-sriv✓github.com/<user>URL tokenMulti-word prose with no
@or URL is ambiguous, so it refuses to guess and returnsNone(the caller then asks the core-team member to use/nf-core github add <username>). All stripping and validation is delegated to the existingnormalise_github_username.2. Account-existence guard (
invite_flow.py)invite_and_greetnow verifies the account exists (GET /users/{username}) before any invite, so typo'd or non-existent handles are rejected up front with a clear message — belt-and-braces on top of the extraction fix.Tests
@mention-only._user_existsautouse fixture lives inconftest.py.Full suite: 425 passed.
ruff check,ruff format, andmypyclean (no new errors).🤖 Generated with Claude Code