langgenius/dify · error · NotFound

App not found

Error message

App not found

What it means

Raised in the app-copy flow after AppService.copy_app returns a result.app_id, when the subsequent SELECT of App by that id yields None. Indicates the freshly copied app row is missing — typically a transaction rollback or concurrent deletion between insert and read. Surfaces as NotFound (404).

Source

Thrown at api/controllers/console/app/app.py:1017

            session.commit()

            # Inherit web app permission from original app
            if result.app_id and FeatureService.get_system_features().webapp_auth.enabled:
                try:
                    # Get the original app's access mode
                    original_settings = EnterpriseService.WebAppAuth.get_app_access_mode_by_id(app_model.id)
                    access_mode = original_settings.access_mode
                except Exception:
                    # If original app has no settings (old app), default to public to match fallback behavior
                    access_mode = "public"

                # Apply the same access mode to the copied app
                EnterpriseService.WebAppAuth.update_app_access_mode(result.app_id, access_mode)

            stmt = select(App).where(App.id == result.app_id)
            app = session.scalar(stmt)
            if not app:
                raise NotFound("App not found")

            permission_keys_map = enterprise_rbac_service.RBACService.AppPermissions.batch_get(
                str(current_tenant_id),
                current_user.id,
                [str(app.id)],
                session=session,
            )
            response_model = AppDetailWithSite.model_validate(
                app,
                from_attributes=True,
                context={"session": session},
            ).model_copy(update={"permission_keys": permission_keys_map.get(str(app.id), [])})
            return response_model.model_dump(mode="json"), 201


@console_ns.route("/apps/<uuid:app_id>/export")
class AppExportApi(Resource):
    @console_ns.doc("export_app")

View on GitHub (pinned to ef8544b173)

Solutions

  1. Retry the copy request once — transient race or rollback often clears.
  2. Check DB logs for transaction rollbacks around the copy time.
  3. Confirm EnterpriseService.WebAppAuth.update_app_access_mode is healthy when webapp_auth is enabled.
  4. Verify primary/replica consistency if reads are routed to a replica.
Defensive patterns

Strategy: retry

Try / catch

try { return await axios.post(`/apps/${id}/copy`, payload); }
catch (e) { if (/App not found/.test(e.message)) { /* retry once; if still failing, escalate */ } }

Prevention

When it happens

Trigger: POST /console/apps/{app_id}/copy succeeds in copy_app but the follow-up lookup of the new app returns nothing: transaction rolled back, the copy was deleted by another request, or an enterprise webapp_auth side effect raised silently before the read.

Common situations: Concurrent deletion of the copied app; database replica lag if reads go to a replica; enterprise webapp_auth update_app_access_mode raises and the surrounding transaction is rolled back; out-of-storage during insert.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/a5dc94dc9d175945. Report an issue: GitHub.