Skip to content

Commit 089e7aa

Browse files
authored
fix(frontend): Catch exception on agent listing page (#9923)
Listing page throws exception on deployment because of supabase auth issue. ### Changes 🏗️ Catch the exception when getting library agent. This reverts the behavior of listing page and it'll always show "Add to Library" when user is logged in. ### Checklist 📋 #### For code changes: - [ ] I have clearly listed my changes in the PR description - [ ] I have made a test plan - [ ] I have tested my changes according to the test plan: - [ ] ...
1 parent 74e6a6a commit 089e7aa

File tree

1 file changed

+8
-7
lines changed
  • autogpt_platform/frontend/src/app/(platform)/marketplace/agent/[creator]/[slug]

1 file changed

+8
-7
lines changed

autogpt_platform/frontend/src/app/(platform)/marketplace/agent/[creator]/[slug]/page.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AgentsSection } from "@/components/agptui/composite/AgentsSection";
66
import { BecomeACreator } from "@/components/agptui/BecomeACreator";
77
import { Separator } from "@/components/ui/separator";
88
import { Metadata } from "next";
9-
import getServerSupabase from "@/lib/supabase/getServerSupabase";
9+
import getServerUser from "@/lib/supabase/getServerUser";
1010

1111
export async function generateMetadata({
1212
params,
@@ -37,20 +37,21 @@ export default async function Page({
3737
params: { creator: string; slug: string };
3838
}) {
3939
const creator_lower = params.creator.toLowerCase();
40+
const { user } = await getServerUser();
4041
const api = new BackendAPI();
4142
const agent = await api.getStoreAgent(creator_lower, params.slug);
4243
const otherAgents = await api.getStoreAgents({ creator: creator_lower });
4344
const similarAgents = await api.getStoreAgents({
4445
// We are using slug as we know its has been sanitized and is not null
4546
search_query: agent.slug.replace(/-/g, " "),
4647
});
47-
const {
48-
data: { user },
49-
} = await getServerSupabase().auth.getUser();
5048
const libraryAgent = user
51-
? await api.getLibraryAgentByStoreListingVersionID(
52-
agent.store_listing_version_id,
53-
)
49+
? await api
50+
.getLibraryAgentByStoreListingVersionID(agent.store_listing_version_id)
51+
.catch((error) => {
52+
console.error("Failed to fetch library agent:", error);
53+
return null;
54+
})
5455
: null;
5556

5657
const breadcrumbs = [

0 commit comments

Comments
 (0)