Skip to content

Conversation

@ycdzj
Copy link
Contributor

@ycdzj ycdzj commented Nov 3, 2025

  • refactor(names): add blocked-names
  • refactor(names): add Chinese blocked names
  • refactor(namespaces): check blocked names

Copilot AI review requested due to automatic review settings November 3, 2025 09:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the blocked names utility to support both usernames and namespace names, expanding its scope beyond just user accounts. The refactoring includes renaming the module, adding Chinese translations of blocked terms, and applying the validation to namespace creation.

Key changes:

  • Renamed blocked-usernames.ts to blocked-names.ts with corresponding function/variable renames
  • Added 254 Chinese translations of common blocked terms to the blocklist
  • Extended blocked name validation to namespace creation
  • Added .trim() call in the validation function to handle whitespace

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/utils/blocked-names.ts Renamed from blocked-usernames.ts, added Chinese blocked terms, removed duplicate 'sysadmin' entry, renamed constants and function, added trim() to validation
src/user/user.service.ts Updated imports and function calls to use new isNameBlocked function
src/namespaces/namespaces.service.ts Added blocked name validation to namespace creation via new import and check
Comments suppressed due to low confidence (1)

src/namespaces/namespaces.service.ts:223

  • The update method validates namespace name conflicts but does not check if the new name is blocked using isNameBlocked. This inconsistency allows updating a namespace to a blocked name even though creating one with a blocked name is prevented.
    if (updateDto.name && updateDto.name !== namespace.name) {
      if ((await repo.countBy({ name: updateDto.name })) > 0) {
        const message = this.i18n.t('namespace.errors.namespaceConflict');
        throw new AppException(
          message,
          'NAMESPACE_CONFLICT',
          HttpStatus.CONFLICT,
        );
      }
      namespace.name = updateDto.name;
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LucienShui LucienShui merged commit a5e9061 into main Nov 3, 2025
5 checks passed
@LucienShui LucienShui deleted the refactor/blocked_names branch November 3, 2025 12:50
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.

3 participants