Fix workspace slug normalization for accented names#9162
Conversation
Normalize workspace slug input before validation and submission so accented names like çã are converted to ASCII-safe slugs (e.g. ca). Also normalize slug availability checks and add serializer coverage for the normalization path.
|
|
📝 WalkthroughWalkthroughThis PR standardizes workspace slug handling across the application by introducing a shared ChangesUnified Workspace Slug Normalization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82712457c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .replace(/\s+/g, "-") | ||
| .replace(/[^a-z0-9_-]/g, "") | ||
| .replace(/-+/g, "-") | ||
| .replace(/^-+|-+$/g, ""); |
There was a problem hiding this comment.
Preserve typed hyphen separators in slug inputs
Because the updated workspace URL fields call normalizeSlug on every onChange, this trailing-hyphen strip makes manual slugs with hyphen separators effectively untypeable: after a user types acme-, the stored value immediately becomes acme, so the next character produces acmeteam instead of acme-team. This affects the create-workspace slug inputs that were changed to store normalizeSlug(e.target.value); consider only trimming edge hyphens on submit/blur or using a less destructive live normalizer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/core/services/workspace.service.ts (1)
200-206: 💤 Low valueConsider using
paramsobject for consistency.While the
encodeURIComponentapproach is correct, other methods in this file use theparamsobject for query parameters (e.g.,searchWorkspaceat line 216,searchEntityat line 331). Usingparamswould be more consistent and eliminates the need for manual encoding:♻️ Optional refactor for consistency
async workspaceSlugCheck(slug: string): Promise<any> { - return this.get(`/api/workspace-slug-check/?slug=${encodeURIComponent(slug)}`) + return this.get(`/api/workspace-slug-check/`, { + params: { slug }, + }) .then((response) => response?.data) .catch((error) => { throw error?.response?.data; }); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/core/services/workspace.service.ts` around lines 200 - 206, The workspaceSlugCheck function currently builds a manual query string with encodeURIComponent; change it to pass the slug via a params object to this.get for consistency with searchWorkspace/searchEntity and to avoid manual encoding: update workspaceSlugCheck (the async workspaceSlugCheck(slug: string): Promise<any>) to call this.get('/api/workspace-slug-check/', { params: { slug } }) and preserve the existing .then(response => response?.data).catch(error => { throw error?.response?.data; }) behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/web/core/services/workspace.service.ts`:
- Around line 200-206: The workspaceSlugCheck function currently builds a manual
query string with encodeURIComponent; change it to pass the slug via a params
object to this.get for consistency with searchWorkspace/searchEntity and to
avoid manual encoding: update workspaceSlugCheck (the async
workspaceSlugCheck(slug: string): Promise<any>) to call
this.get('/api/workspace-slug-check/', { params: { slug } }) and preserve the
existing .then(response => response?.data).catch(error => { throw
error?.response?.data; }) behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9f8c1170-089b-4cbc-854f-6d5af2e89a8d
📒 Files selected for processing (9)
apps/admin/app/(all)/(dashboard)/workspace/create/form.tsxapps/api/plane/license/api/serializers/workspace.pyapps/api/plane/license/api/views/workspace.pyapps/api/plane/tests/unit/serializers/test_workspace.pyapps/web/core/components/onboarding/create-workspace.tsxapps/web/core/components/onboarding/steps/workspace/create.tsxapps/web/core/components/workspace/create-workspace-form.tsxapps/web/core/services/workspace.service.tspackages/utils/src/validation.ts
What\n- Normalize workspace slug input before submission so names with accents/diacritics (e.g. "çã") become ASCII-safe slugs (e.g. "ca")\n- Normalize slug availability checks in the backend\n- Add serializer coverage for slug normalization\n\n## Why\nThe workspace creation flow could send non-ASCII slugs to the API, which resulted in 400 responses even though the workspace name itself was valid.\n\n## Verification\n- python3 -m py_compile on the touched Python files\n- git diff --check
Summary by CodeRabbit