Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: --name option for the create-tenant command does not take effect #11993

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

euxx
Copy link
Contributor

@euxx euxx commented Dec 23, 2024

Summary

Fixes #11991

The issue is:

When run create_tenant command, it first registers an account, and then call create_owner_tenant_if_not_exist method. (api/commands.py:565

However, a default tenant will be created during the register account process.

    # api/services/account_service.py:815
    def register(
        ...
    ) -> Account:
        create account...

            if FeatureService.get_system_features().is_allow_create_workspace:
                tenant = TenantService.create_tenant(f"{account.name}'s Workspace")

Therefore, a tenant will always exist when create_owner_tenant_if_not_exist is called, and won't create a tenant with --name option.

    # api/services/account_service.py:517
    # available_ta will always be true
    def create_owner_tenant_if_not_exist(
        account: Account, name: Optional[str] = None, is_setup: Optional[bool] = False
    ):
        """Check if user have a workspace or not"""
        available_ta = (
            TenantAccountJoin.query.filter_by(account_id=account.id).order_by(TenantAccountJoin.id.asc()).first()
        )

        if available_ta:
            return

Screenshots

Run command:

cd api
poetry run python -m flask create-tenant --email '[email protected]' --name "Custom Tenant" --language 'zh-Hans'
Before After
image image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working labels Dec 23, 2024
@crazywoola crazywoola requested a review from laipz8200 December 23, 2024 07:22
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 24, 2024
@crazywoola crazywoola merged commit 49bc602 into langgenius:main Dec 24, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--name option for the create-tenant command does not take effect
3 participants