{"record":{"id":"32465dbcd72ca6a2","repo":"langgenius/dify","slug":"no-workflow-or-advanced-chat-apps-found-for-the-se","errorCode":null,"errorMessage":"No workflow or advanced-chat apps found for the selected tenant.","messagePattern":"No workflow or advanced-chat apps found for the selected tenant\\.","errorType":"console","errorClass":"MigrationDataError","httpStatus":null,"severity":"error","filePath":"api/commands/data_migration.py","lineNumber":335,"sourceCode":"    tenant_index = click.prompt(\"Select one source tenant by number\", type=int, default=1, show_default=True)\n    if tenant_index < 1 or tenant_index > len(tenants):\n        raise click.ClickException(f\"Selection index out of range: {tenant_index}\")\n    return tenants[tenant_index - 1]\n\n\ndef _eligible_apps_for_tenant(tenant_id: str) -> list[App]:\n    return list(\n        db.session.scalars(\n            sa.select(App)\n            .where(App.tenant_id == tenant_id, App.mode.in_(SUPPORTED_WIZARD_APP_MODES))\n            .order_by(App.name.asc())\n        ).all()\n    )\n\n\ndef _prompt_app_ids(apps: list[App]) -> list[str]:\n    if not apps:\n        raise MigrationDataError(\"No workflow or advanced-chat apps found for the selected tenant.\")\n\n    _print_wizard_step(\"App Selection\")\n    click.echo(\"Currently supported app types: workflow and chatflow.\")\n    click.echo(\"Workflow/chatflow apps:\")\n    for index, app in enumerate(apps, 1):\n        mode = app.mode.value if hasattr(app.mode, \"value\") else app.mode\n        click.echo(f\"{index}. {app.name} [{mode}] ({app.id})\")\n    app_ids = parse_index_selection(\n        click.prompt(\"Select apps by number, comma-separated numbers, or all\", default=\"all\"),\n        [app.id for app in apps],\n    )\n    selected_apps = [app for app in apps if app.id in set(app_ids)]\n    click.echo(\"Selected apps:\")\n    for app in selected_apps:\n        click.echo(f\"- {app.name} ({app.id})\")\n    return app_ids\n\n","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/commands/data_migration.py#L317-L353","documentation":"MigrationDataError raised by _prompt_app_ids when _eligible_apps_for_tenant returns an empty list. Eligible apps are those whose mode is in SUPPORTED_WIZARD_APP_MODES (workflow and advanced-chat/chatflow). If the selected tenant has none, the wizard cannot proceed.","triggerScenarios":"Triggered when the selected tenant has zero App rows with mode in SUPPORTED_WIZARD_APP_MODES - i.e. only completion/basic apps exist, or no apps at all for that tenant.","commonSituations":"The tenant only contains agent or completion apps (unsupported modes), the tenant was mis-selected, or the apps were soft-deleted/archived in a way that filters them out.","solutions":["Run `SELECT id, name, mode FROM apps WHERE tenant_id = '<id>';` to inspect available app types.","Select a different source tenant that has workflow/chatflow apps.","Confirm SUPPORTED_WIZARD_APP_MODES matches the app modes you expect to export.","If the tenant should have eligible apps, verify the apps are not in a deleted state."],"exampleFix":"# before - tenant has only completion apps\n# SELECT mode, count(*) FROM apps WHERE tenant_id='t1' GROUP BY mode;\n#  completion | 5\n\n# after - pick tenant with workflow apps\n#  workflow   | 3\n#  chat       | 2","handlingStrategy":"validation","validationCode":"from sqlalchemy import select\nfrom models import App\n\ndef eligible_app_count(session, tenant_id: str) -> int:\n    return session.scalar(\n        select(func.count()).select_from(App)\n        .where(App.tenant_id == tenant_id, App.mode.in_(SUPPORTED_WIZARD_APP_MODES))\n    ) or 0","typeGuard":"def has_eligible_apps(session, tenant_id: str) -> bool:\n    return session.scalars(\n        select(App).where(App.tenant_id == tenant_id, App.mode.in_(SUPPORTED_WIZARD_APP_MODES)).limit(1)\n    ).first() is not None","tryCatchPattern":"try:\n    app_ids = _prompt_app_ids(apps)\nexcept MigrationDataError as exc:\n    click.echo(str(exc), err=True)\n    raise click.Abort()","preventionTips":["Before running the wizard, confirm the tenant has workflow/chatflow apps via `SELECT mode, count(*) FROM apps WHERE tenant_id='<id>' GROUP BY mode;`.","Pick a source tenant that has supported app modes.","Keep SUPPORTED_WIZARD_APP_MODES in sync with the modes you intend to export.","Filter out deleted apps in preflight if the schema supports soft deletes."],"tags":["backend","cli","data-migration","database","app-mode","empty-state"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}