{"record":{"id":"44e8474ffb0ee9ec","repo":"langgenius/dify","slug":"agent-has-not-been-published","errorCode":null,"errorMessage":"Agent has not been published","messagePattern":"Agent has not been published","errorType":"http","errorClass":"AgentAppNotPublishedError","httpStatus":null,"severity":"error","filePath":"api/controllers/common/agent_app_parameters.py","lineNumber":39,"sourceCode":"    app_model_config = app_model.app_model_config_with_session(session=session)\n\n    agent_id = app_model.bound_agent_id\n    if not agent_id:\n        raise AgentAppGeneratorError(\"Agent App has no bound Agent\")\n\n    agent = session.scalar(\n        select(Agent)\n        .where(\n            Agent.tenant_id == app_model.tenant_id,\n            Agent.id == agent_id,\n            Agent.status == AgentStatus.ACTIVE,\n        )\n        .limit(1)\n    )\n    if agent is None:\n        raise AgentAppGeneratorError(\"Agent App has no bound Agent\")\n    if not agent_has_workflow_callable_active_snapshot(session=session, agent=agent):\n        raise AgentAppNotPublishedError(\"Agent has not been published\")\n\n    snapshot = session.scalar(\n        select(AgentConfigSnapshot)\n        .where(\n            AgentConfigSnapshot.tenant_id == app_model.tenant_id,\n            AgentConfigSnapshot.agent_id == agent.id,\n            AgentConfigSnapshot.id == agent.active_config_snapshot_id,\n        )\n        .limit(1)\n    )\n    if snapshot is None:\n        raise AgentAppGeneratorError(\"Agent published version not found\")\n\n    agent_soul = AgentSoulConfig.model_validate(snapshot.config_snapshot_dict)\n    annotation_reply = load_annotation_reply_config(session, app_model.id) if app_model_config else None\n    features_dict = merge_agent_app_features(\n        agent_soul=agent_soul,\n        app_model_config=app_model_config,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/common/agent_app_parameters.py#L21-L57","documentation":"Raised as AgentAppNotPublishedError when fetching a published Agent App's parameters: the App has a bound Agent in ACTIVE status, but that Agent has no workflow-callable active config snapshot (no published version). Dify refuses to expose app parameters until the Agent has been published so callers never read a half-configured app. It surfaces a state-machine violation, not a missing resource.","triggerScenarios":"Calling the Agent App parameters/feature endpoint (the shared agent_app_parameters resolver used by console parameters + chat bootstrap) for an App whose bound Agent was created in the composer but never published, or whose published snapshot was later deactivated. Reproducible: create an Agent App, save a draft, do not hit Publish, then GET /console/apps/<app_id>/parameters or open the chat page.","commonSituations":"New Agent App left in draft state before sharing or embedding; publishing failed silently upstream and active_config_snapshot_id remained null; a copy/import of an App that did not carry over the Agent snapshot; CI/tests that create the App+Agent fixtures but skip the publish step.","solutions":["Open the Agent in the console and click Publish to create an active config snapshot, then retry the parameters call.","Verify agent.active_config_snapshot_id is non-null and the referenced AgentConfigSnapshot row is workflow-callable via agent_has_workflow_callable_active_snapshot.","If publishing repeatedly fails, inspect AgentComposerService.publish logs for snapshot creation errors and resolve the underlying DB/storage failure before retrying.","In tests/fixtures, drive the full publish flow (or insert an AgentConfigSnapshot + set active_config_snapshot_id) instead of only creating the Agent row."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from sqlalchemy import select\nfrom models.agent import Agent, AgentStatus\nfrom core.agent.publish_visibility import agent_has_workflow_callable_active_snapshot\n\ndef assert_agent_published(session, app_model) -> None:\n    agent_id = getattr(app_model, 'bound_agent_id', None)\n    if not agent_id:\n        raise ValueError('App has no bound Agent')\n    agent = session.scalar(\n        select(Agent).where(\n            Agent.tenant_id == app_model.tenant_id,\n            Agent.id == agent_id,\n            Agent.status == AgentStatus.ACTIVE,\n        )\n    )\n    if agent is None or not agent_has_workflow_callable_active_snapshot(session=session, agent=agent):\n        raise ValueError('Agent is not published; publish it before fetching parameters')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drive the publish step in setup scripts/fixtures right after Agent creation.","Treat agent_has_workflow_callable_active_snapshot as the publish-state gate before any parameters read.","Surface a clear 'Publish required' UI state instead of letting users open chat on draft Agents."],"tags":["agent-app","publish-state","parameters","state-machine"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}