Skip to content

Commit a557447

Browse files
committed
Fix course lookup in StaticDataLayerProvider by courseId
The provider was storing courses by dependency name (e.g., '@skuilder/course-<id>') but getCourseDB() was looking them up by raw courseId. This caused 'Course not found' errors when trying to access courses in static mode. Now extracts courseId from manifest and uses it as the map key for both courseUnpackers and manifests, ensuring consistent lookup.
1 parent 79f544f commit a557447

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/db/src/impl/static/StaticDataLayerProvider.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,18 @@ export class StaticDataLayerProvider implements DataLayerProvider {
7070
throw new Error(`Failed to fetch final content manifest for ${courseName} at ${finalManifestUrl}`);
7171
}
7272
const finalManifest = await finalManifestResponse.json();
73-
74-
this.manifests[courseName] = finalManifest;
73+
74+
// Extract courseId from the manifest to use as the lookup key
75+
const courseId = finalManifest.courseId || finalManifest.courseConfig?.courseID;
76+
if (!courseId) {
77+
throw new Error(`Course manifest for ${courseName} missing courseId`);
78+
}
79+
80+
this.manifests[courseId] = finalManifest;
7581
const unpacker = new StaticDataUnpacker(finalManifest, baseUrl);
76-
this.courseUnpackers.set(courseName, unpacker);
82+
this.courseUnpackers.set(courseId, unpacker);
7783

78-
logger.info(`[StaticDataLayerProvider] Successfully resolved and prepared course: ${courseName}`);
84+
logger.info(`[StaticDataLayerProvider] Successfully resolved and prepared course: ${courseName} (courseId: ${courseId})`);
7985
}
8086
} catch (e) {
8187
logger.error(`[StaticDataLayerProvider] Failed to resolve dependency ${courseName}:`, e);

0 commit comments

Comments
 (0)