Skip to content

Commit 506398c

Browse files
prazgaitisclaude
andcommitted
Fix setup2027Challenge: use getById to get creatorId
listPublic doesn't return creatorId, so fetch full challenge details via getById before creating the new challenge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 14e82c0 commit 506398c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/backend/actions/setup2027Challenge.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export const setup2027Challenge = action({
2828
offset: 0,
2929
});
3030

31-
const source = challenges.find((c: any) => c.name === SOURCE_CHALLENGE);
32-
if (!source) throw new Error(`${SOURCE_CHALLENGE} not found`);
31+
const sourcePublic = challenges.find((c: any) => c.name === SOURCE_CHALLENGE);
32+
if (!sourcePublic) throw new Error(`${SOURCE_CHALLENGE} not found`);
3333

3434
const existing = challenges.find(
3535
(c: any) => c.name === "March Fitness 2027",
@@ -40,10 +40,16 @@ export const setup2027Challenge = action({
4040
);
4141
}
4242

43+
// Get full challenge details (includes creatorId)
44+
const source = await ctx.runQuery(api.queries.challenges.getById, {
45+
challengeId: sourcePublic.id as Id<"challenges">,
46+
});
47+
if (!source) throw new Error(`Could not load ${SOURCE_CHALLENGE} details`);
48+
4349
// Get source activity types
4450
const sourceTypes = await ctx.runQuery(
4551
api.queries.activityTypes.getByChallengeId,
46-
{ challengeId: source.id as Id<"challenges"> },
52+
{ challengeId: sourcePublic.id as Id<"challenges"> },
4753
);
4854

4955
console.log(

0 commit comments

Comments
 (0)