{"record":{"id":"af973d429bc73004","repo":"Significant-Gravitas/AutoGPT","slug":"no-agent-selected-please-select-an-agent-before-s","errorCode":null,"errorMessage":"No agent selected. Please select an agent before submitting to the store.","messagePattern":"No agent selected\\. Please select an agent before submitting to the store\\.","errorType":"exception","errorClass":"ValueError","httpStatus":400,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":897,"sourceCode":"\n        # Sanitize slug to only allow letters and hyphens\n        slug = \"\".join(\n            c if c.isalpha() or c == \"-\" or c.isnumeric() else \"\" for c in slug\n        ).lower()\n\n        # First verify the agent graph belongs to this user\n        graph = await prisma.models.AgentGraph.prisma().find_first(\n            where={\"id\": graph_id, \"version\": graph_version, \"userId\": user_id},\n            include={\"User\": {\"include\": {\"Profile\": True}}},\n        )\n\n        if not graph:\n            logger.warning(\n                f\"Agent graph {graph_id} v{graph_version} not found for user {user_id}\"\n            )\n            # Provide more user-friendly error message when graph_id is empty\n            if not graph_id or graph_id.strip() == \"\":\n                raise ValueError(\n                    \"No agent selected. \"\n                    \"Please select an agent before submitting to the store.\"\n                )\n            else:\n                raise NotFoundError(\n                    f\"Agent #{graph_id} v{graph_version} not found \"\n                    f\"for this user (#{user_id})\"\n                )\n\n        if not graph.User or not graph.User.Profile:\n            logger.warning(f\"User #{user_id} does not have a Profile\")\n            raise PreconditionFailed(\n                \"User must create a Marketplace Profile before submitting an agent\"\n            )\n\n        async with transaction() as tx:\n            # Determine next version number for this listing\n            existing_listing = await prisma.models.StoreListing.prisma(tx).find_unique(","sourceCodeStart":879,"sourceCodeEnd":915,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L879-L915","documentation":"ValueError raised inside create_store_submission when the agent graph lookup fails AND graph_id is empty or whitespace-only. It exists to give the marketplace submission UI an actionable message ('select an agent') instead of a cryptic not-found. Note the lookup itself is scoped to {id, version, userId}, so an empty string never matches and always lands here.","triggerScenarios":"POST /store/submissions with graph_id '' or '   ' — typically a frontend submitting the form before an agent is chosen, or a default-initialized empty agent field in state.","commonSituations":"Submit button enabled with no agent selected in the publish dialog; state reset to '' by a refetch but submission fired from stale closure; automated tests posting empty payloads.","solutions":["Disable the submit button until a valid graph_id is selected in the UI.","Validate client-side: if (!graphId?.trim()) show 'select an agent' instead of calling the API.","In the API layer, declare graph_id as a required min-length-1 field so FastAPI returns 422 before the DB call."],"exampleFix":"// before\n<button onClick={() => submit({ graph_id: selectedAgent?.id ?? '' })}>Publish</button>\n// after\n<button disabled={!selectedAgent} onClick={() => submit({ graph_id: selectedAgent.id })}>Publish</button>","handlingStrategy":"validation","validationCode":"if (!form.graph_id || !form.graph_id.trim()) {\n  setError('Select an agent to publish');\n  return;\n}\nawait api.createSubmission(form);","typeGuard":"function hasSelectedAgent(graphId: string | null | undefined): graphId is string {\n  return typeof graphId === 'string' && graphId.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Disable Publish until an agent is selected.","Model selection as a non-nullable field once chosen; null means unselected.","Add API-level validation (min_length=1) so the boundary rejects empty IDs."],"tags":["validation","submission","store","frontend"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}