Skip to content

[BUG]: AI-generated roadmaps not visible on /roadmaps - missing from both catalogue and "in progress" section #887

@dhaanisi

Description

@dhaanisi

Description

Summary:

When a student generates a custom roadmap via the AI wizard (/roadmaps/generate), the roadmap is saved with isPublished: false and ownerUserId = userId. It never appears on the /roadmaps landing page - not in the public catalogue, and not in the "Pick up where you left off" section - even though the user is enrolled in it.

Steps to Reproduce

  1. Log in as a student.
  2. Go to /roadmaps/generate and complete the AI wizard.
  3. Navigate to /roadmaps (the Career Roadmaps page from the Learning Hub).
  4. Observe: the newly generated roadmap is absent from both the catalogue and the "in progress" section.
  5. Navigate to /student/roadmaps (the dashboard). The roadmap appears there correctly.

Expected Behavior

AI- generated roadmaps owned by the authenticated user should appear in the "Pick up where you left off" section on /roadmaps, even though they are not publicly published.

Actual Behavior

They are invisible. The page only shows roadmaps where isPublished = true.

Root Cause

Three places in the code all need to be aware of the owner-visibility rule:

  1. roadmap.service.ts - listPublishedRoadmaps
// current — only public roadmaps
const where: Prisma.roadmapWhereInput = { isPublished: true };

There is no branch to also include {isPublished: false, ownerUserId: userId} when a logged-in user makes the request.

  1. RoadmapsLandingPage.tsx - inProgress computation
 // GET /roadmaps → only isPublished:true items
// GET /roadmaps/me/enrollments → all enrollments including AI-generated ones
const inProgress = filtered.filter((r) => enrolledBySlug.has(r.slug));

filtered is derived from the public catalogue, so AI-generated roadmap slugs are never in it. The intersection is always empty for those roadmaps.

  1. roadmap.service.ts - enrollUser
const roadmap = await prisma.roadmap.findFirst({
  where: { slug: args.roadmapSlug, isPublished: true }, // blocks owner's own roadmaps
  ...
});

A user cannot re-enroll in their own unpublished roadmap via the standard enroll route.

Proposed Fix

Server: Pass the authenticated userId (optional) into listPublishedRoadmaps and extend the where clause:

const where: Prisma.roadmapWhereInput = {
  OR: [
    { isPublished: true },
    ...(userId ? [{ isPublished: false, ownerUserId: userId }] : []),
  ],
};

Client: RoadmapsLandingPage already fetches /roadmaps/me/enrollments. The "in progress" section should be built from the enrollments list directly (not by intersecting with the public catalogue), so AI-generated roadmaps show up regardless of publish status.
enrollUser: Extend the lookup to also allow ownerUserId = userId:

where: {
  slug: args.roadmapSlug,
  OR: [{ isPublished: true }, { ownerUserId: args.userId }],
},

Screenshots / Logs

Image Image

OS

No response

Browser

No response

Version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggssoctype:bugBug fixestype:designUI/UX or design-related updatestype:securitySecurity-related fixes or improvements

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions