Handling None Values in installed_app Causes Frontend Display Issues #5295

Closed
opened 2026-02-21 18:10:18 -05:00 by yindo · 2 comments
Owner

Originally created by @YidaHu on GitHub (Aug 29, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.7.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Navigate to the application installation page.
  2. Ensure there is at least one installed application with its app attribute set to None.
  3. Observe the list of installed applications displayed on the page.

image

image

image

✔️ Expected Behavior

The page should display correctly without any errors or blank sections.

Actual Behavior

When installed_app.app is None, this None value is directly passed to the frontend, leading to incomplete or erroneous display.

Originally created by @YidaHu on GitHub (Aug 29, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.7.2 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. Navigate to the application installation page. 2. Ensure there is at least one installed application with its app attribute set to None. 3. Observe the list of installed applications displayed on the page. ![image](https://github.com/user-attachments/assets/6ee9d93a-f67c-4801-837a-2dbc49691a71) ![image](https://github.com/user-attachments/assets/be26e2f8-3908-43cd-be3b-95d95b41550a) ![image](https://github.com/user-attachments/assets/cf58bbc1-e6f6-471a-a8b1-ba2946a63620) ### ✔️ Expected Behavior The page should display correctly without any errors or blank sections. ### ❌ Actual Behavior When installed_app.app is None, this None value is directly passed to the frontend, leading to incomplete or erroneous display.
yindo added the 🐞 bug label 2026-02-21 18:10:18 -05:00
yindo closed this issue 2026-02-21 18:10:18 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 29, 2024):

To fix the issue where a None value in installed_app causes frontend display problems in version 0.7.2 of the self-hosted Dify application, you need to ensure that the app attribute of each installed_app is not None before processing it. You can add a check in the list comprehension that constructs the installed_apps list to filter out any installed_app entries where app is None.

Here is the modified code:

class InstalledAppsListApi(Resource):
    @login_required
    @account_initialization_required
    @marshal_with(installed_app_list_fields)
    def get(self):
        current_tenant_id = current_user.current_tenant_id
        installed_apps = db.session.query(InstalledApp).filter(InstalledApp.tenant_id == current_tenant_id).all()

        current_user.role = TenantService.get_user_role(current_user, current_user.current_tenant)
        installed_apps = [
            {
                "id": installed_app.id,
                "app": installed_app.app,
                "app_owner_tenant_id": installed_app.app_owner_tenant_id,
                "is_pinned": installed_app.is_pinned,
                "last_used_at": installed_app.last_used_at,
                "editable": current_user.role in ["owner", "admin"],
                "uninstallable": current_tenant_id == installed_app.app_owner_tenant_id,
            }
            for installed_app in installed_apps if installed_app.app is not None
        ]
        installed_apps.sort(
            key=lambda app: (
                -app["is_pinned"],
                app["last_used_at"] is None,
                -app["last_used_at"].timestamp() if app["last_used_at"] is not None else 0,
            )
        )

        return {"installed_apps": installed_apps}

This change ensures that only installed_app entries with a non-None app attribute are included in the installed_apps list, preventing any None values from causing frontend display problems [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 29, 2024): <!-- Answer --> To fix the issue where a `None` value in `installed_app` causes frontend display problems in version 0.7.2 of the self-hosted Dify application, you need to ensure that the `app` attribute of each `installed_app` is not `None` before processing it. You can add a check in the list comprehension that constructs the `installed_apps` list to filter out any `installed_app` entries where `app` is `None`. Here is the modified code: ```python class InstalledAppsListApi(Resource): @login_required @account_initialization_required @marshal_with(installed_app_list_fields) def get(self): current_tenant_id = current_user.current_tenant_id installed_apps = db.session.query(InstalledApp).filter(InstalledApp.tenant_id == current_tenant_id).all() current_user.role = TenantService.get_user_role(current_user, current_user.current_tenant) installed_apps = [ { "id": installed_app.id, "app": installed_app.app, "app_owner_tenant_id": installed_app.app_owner_tenant_id, "is_pinned": installed_app.is_pinned, "last_used_at": installed_app.last_used_at, "editable": current_user.role in ["owner", "admin"], "uninstallable": current_tenant_id == installed_app.app_owner_tenant_id, } for installed_app in installed_apps if installed_app.app is not None ] installed_apps.sort( key=lambda app: ( -app["is_pinned"], app["last_used_at"] is None, -app["last_used_at"].timestamp() if app["last_used_at"] is not None else 0, ) ) return {"installed_apps": installed_apps} ``` This change ensures that only `installed_app` entries with a non-`None` `app` attribute are included in the `installed_apps` list, preventing any `None` values from causing frontend display problems <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/controllers/console/explore/installed_app.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Aug 29, 2024):

Here are few things needs to be clarified

  • Is this application removed or deleted?
  • Have you started the celery worker?
@crazywoola commented on GitHub (Aug 29, 2024): Here are few things needs to be clarified - Is this application removed or deleted? - Have you started the celery worker?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5295