Skip to content

🧪 [testing improvement] Add missing username validation edge case tests#74

Merged
is0692vs merged 2 commits intomainfrom
fix/test-username-validators-15745143920105382679
Mar 21, 2026
Merged

🧪 [testing improvement] Add missing username validation edge case tests#74
is0692vs merged 2 commits intomainfrom
fix/test-username-validators-15745143920105382679

Conversation

@is0692vs
Copy link
Contributor

🎯 What: The isValidGitHubUsername function in src/lib/validators.ts was missing test coverage for several important edge cases, making the validation logic susceptible to regressions.
📊 Coverage: Added test cases for multibyte characters (Kanji, emojis), whitespace and control characters, purely hyphenated strings, and extremely long strings (to check for ReDoS).
Result: Test coverage for isValidGitHubUsername is significantly improved, ensuring the regular expression robustness against invalid username patterns.


PR created automatically by Jules for task 15745143920105382679 started by @is0692vs

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link

vercel bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
github-user-summary Ready Ready Preview, Comment Mar 21, 2026 4:36am

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on bolstering the reliability and security of the isValidGitHubUsername function. By introducing comprehensive test cases for previously unaddressed edge scenarios, such as multibyte characters, whitespace, and potential ReDoS attack vectors, the changes ensure the validation logic is more resilient and less prone to regressions, ultimately enhancing the integrity of username handling.

Highlights

  • Test Coverage Improvement: Enhanced the test suite for the isValidGitHubUsername function by adding new test cases for critical edge scenarios.
  • Edge Case Validation: Introduced tests to validate multibyte characters (e.g., Japanese, emojis), whitespace, control characters, strings composed solely of hyphens, and extremely long strings to prevent ReDoS vulnerabilities.
  • Regular Expression Robustness: Significantly improved the robustness of the username validation regular expression by ensuring it correctly handles various invalid patterns.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9cb782bb-812d-41bc-9480-f44cf5fec6f5

📥 Commits

Reviewing files that changed from the base of the PR and between b711fdc and efd02a2.

📒 Files selected for processing (1)
  • src/lib/__tests__/validators.test.ts

📝 Walkthrough

Summary by CodeRabbit

リリースノート

  • Tests
    • GitHubユーザー名検証の単体テストを拡充しました。マルチバイト文字(日本語・絵文字・アクセント付き文字)を含むケース、空白や改行・タブ・NULなどの制御文字を含むケース、極端に長い(長さ1000)入力の無効扱いを検証するテストを追加しました。

Walkthrough

isValidGitHubUsername のユニットテストを拡張し、非ASCII/マルチバイト文字、ホワイトスペース/制御文字(先頭末尾スペース、改行、タブ、NUL)、および長さ1000の文字列を含む無効ケースを追加しました。

Changes

Cohort / File(s) Summary
Test Case Expansion
src/lib/__tests__/validators.test.ts
isValidGitHubUsername に対し、非ASCII・マルチバイト文字(日本語、絵文字、アクセント文字)、ホワイトスペース・制御文字(先頭/末尾スペース、改行、タブ、NUL)、および長さ1000の長文字列を含む無効ケーステストを追加(+19 行)。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 テスト増えたよ、ぴょんぴょんと
不正文字も、空白も、NULも蹴散らす
長い文字列もにっこり受け止め
バリデータ、堅く守るよ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは、主な変更内容(isValidGitHubUsername関数のテストカバレッジ拡大)を明確に説明しており、変更セットに完全に関連している。
Description check ✅ Passed 説明は、追加されたテストケース(マルチバイト文字、ホワイトスペース、制御文字、長い文字列)について詳しく述べており、変更セットに完全に関連している。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/test-username-validators-15745143920105382679

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

このプルリクエストでは、isValidGitHubUsername 関数のバリデーションロジックに対して、これまでカバーされていなかった複数のエッジケースを検証するテストが追加されました。これにより、テストスイートの堅牢性が向上します。追加されたテストは概ね的確ですが、一部に既存テストとの重複や、説明が誤解を招く可能性のある箇所が見受けられました。詳細については、具体的な改善提案をコメントとして記載しましたので、ご確認ください。

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/__tests__/validators.test.ts`:
- Around line 101-103: Rename the test description so it reflects that it's
checking length-based validation rather than ReDoS resistance: update the `it`
title that wraps the
`expect(isValidGitHubUsername("a".repeat(1000))).toBe(false)` assertion to
something like "極端に長い文字列は無効 (長さ上限の確認)" or similar; keep the assertion and the
use of isValidGitHubUsername unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 961e43d1-ba22-4dd9-b0d5-185b3adff0b6

📥 Commits

Reviewing files that changed from the base of the PR and between 87d145d and b711fdc.

📒 Files selected for processing (1)
  • src/lib/__tests__/validators.test.ts

@is0692vs is0692vs merged commit 8b88305 into main Mar 21, 2026
7 checks passed
@is0692vs is0692vs deleted the fix/test-username-validators-15745143920105382679 branch March 21, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant