{"record":{"id":"ffeb8656449e0d47","repo":"iflytek/astron-agent","slug":"app-not-found-error","errorCode":"APP_NOT_FOUND_ERROR","errorMessage":"App not found for nested workflow execution: {self.appId}","messagePattern":"App not found for nested workflow execution: (.+?)","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/flow/flow_node.py","lineNumber":395,"sourceCode":"                    \"req_body\": json.dumps(req_body, ensure_ascii=False),\n                }\n            )\n\n        # Query application credentials from database\n        with session_getter() as session:\n            start_time = time.time() * 1000\n            app = session.query(App).filter_by(alias_id=self.appId).first()\n\n            # Log database query performance\n            await span.add_info_events_async(\n                {\n                    \"flow_node_get_appid_from_database\": f\"{time.time() * 1000 - start_time}\"\n                }\n            )\n\n            # Validate app existence\n            if not app or app.id == 0:\n                raise CustomException(\n                    err_code=CodeEnum.APP_NOT_FOUND_ERROR,\n                    err_msg=f\"App not found for nested workflow execution: {self.appId}\",\n                )\n\n            # Construct authorization header\n            authorization = f\"Bearer {app.api_key}:{app.api_secret}\"\n\n        # Set authentication headers based on runtime environment\n        if not os.getenv(\"RUNTIME_ENV\", RuntimeEnv.Local.value) in [\n            RuntimeEnv.Dev.value,\n            RuntimeEnv.Test.value,\n        ]:\n            # Use bearer token for production environments\n            headers[\"Authorization\"] = authorization\n        else:\n            # Development/test calls use a trusted identity only when the same\n            # deployment-internal credential is present.\n            internal_api_key = credential_from_env_or_file(","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/flow/flow_node.py#L377-L413","documentation":"The flow node looks up the target app (nested workflow) by appId in the database before calling its API. When the query returns None or an app with id==0 the node raises APP_NOT_FOUND_ERROR, because it cannot obtain the api_key/api_secret needed to authorize the nested call.","triggerScenarios":"_assemble_request fetches the app for self.appId and gets no row (or a placeholder id=0), typically right after the 'flow_node_get_appid_from_database' timing log.","commonSituations":"Nested workflow's app was deleted or unpublished; appId copied from another environment/tenant; typo in app configuration; database replication lag in multi-region setups.","solutions":["Verify the appId configured on the flow node exists in the target environment's app table","Re-select the nested workflow app in the flow node editor and re-save the node","Check tenant/space isolation — the app must belong to a space the executing user can access","Restore or republish the app if it was deleted or unpublished"],"exampleFix":"// before\nappId = \"wf_12345\"  // deleted app\n// after\nappId = \"wf_67890\"  // re-selected published nested workflow app","handlingStrategy":"validation","validationCode":"app = app_repository.get_by_id(flow_node.appId)\nif app is None or app.id == 0:\n    raise ConfigError(f'flow node references missing app {flow_node.appId}')","typeGuard":"def app_exists(app) -> bool:\n    return app is not None and getattr(app, 'id', 0) != 0","tryCatchPattern":"try:\n    outputs = await flow_node.async_execute(ctx)\nexcept CustomException as e:\n    if e.err_code == CodeEnum.APP_NOT_FOUND_ERROR:\n        notify_owner(f'app {flow_node.appId} missing; republish or rebind node')\n    raise","preventionTips":["Verify appId after copying workflows between environments","Never delete apps still referenced by other workflows; check references first","Re-select the nested workflow in the editor after any app migration"],"tags":["workflow","database","config"],"backgroundTag":"entity-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}