fix: allow users to open projects with accessible environments#3395
Merged
Siumauricio merged 4 commits intoDokploy:canaryfrom Jan 21, 2026
Merged
fix: allow users to open projects with accessible environments#3395Siumauricio merged 4 commits intoDokploy:canaryfrom
Siumauricio merged 4 commits intoDokploy:canaryfrom
Conversation
- Update environment selection to fallback to first accessible environment when default is not accessible - Fix search command to handle users without default environment access - Fix projects list to use accessible environment instead of always default - Add server-side redirect to accessible environment when accessing inaccessible one - Add comprehensive test coverage for environment access fallback logic Fixes Dokploy#3394
- Implemented a check for projects with no accessible environments, displaying an alert message to inform users. - Updated project link behavior to prevent navigation when no environments are available, enhancing user experience.
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.
What is this PR about?
This PR fixes a bug where users with restricted environment access (e.g., only
developmentbut notproduction) couldn't open projects because the application always tried to navigate to the default environment. The fix ensures that when opening a project, we first try the default environment if accessible, otherwise fall back to the first accessible environment. This makes the permission system work as intended and allows users with restricted access to still work with projects they have permission to view.Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
Fixes #3394
Changes Made
Core Fix
Updated the environment selection logic in three locations to handle users without access to the default environment:
Search Command (
apps/dokploy/components/dashboard/search-command.tsx):Projects List (
apps/dokploy/components/dashboard/projects/show.tsx):productionEnvironmentlookup withaccessibleEnvironmentthat uses fallback logicServer-Side Redirect (
apps/dokploy/pages/dashboard/project/[projectId]/environment/[environmentId].tsx):Technical Details
The backend already filters environments correctly - the
project.allquery returns only environments the user has access to for members. The issue was that the frontend code didn't account for this filtering and still tried to find the default from what it assumed was the full list.The fix is straightforward: since the environments array is already filtered for members, we select from that filtered list. We try the default first (if it exists in the accessible list), otherwise we grab the first one available.
Testing
Added comprehensive test coverage in
apps/dokploy/__test__/env/environment-access-fallback.test.ts:Backward Compatibility
This change is fully backward compatible. Users who have access to the default environment will see no change in behavior. The fix only improves the experience for users with restricted access.
Testing Instructions
To verify the fix:
production(default) anddevelopmentenvironmentsdevelopmentenvironment