External routes ignore params
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Start with runtime/routing/utils.ts and runtime/routing/utils.test.ts, especially the existing test for an external route with params; then read types.ts and the migration guide’s URL Config section. The issue establishes that absolute external URLs currently ignore params, but leaves the intended behavior and URL syntax open. Done means the behavior is decided and implemented with tests and matching documentation.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
External routes ignore params. resolveRouteByRole(role, { courseId }) uses courseId when an installed app provides the role, and ignores it when an external route does.
Found while porting Learning's progress tab (openedx/frontend-app-learning#2190), which links to course pages by role. Related to #348.
[!NOTE]
The details below were generated by Claude (Claude Code) and reviewed before posting.
Claude Plan
How a role with params resolves today
- A role is declared on a route, and the route's path decides which params the role takes:
/gradebook/:courseIdcarriesorg.openedx.frontend.role.gradebook(src/routes.tsxin openedx/frontend-app-gradebook),instructor-dashboard/:courseIdcarriesorg.openedx.frontend.role.instructorDashboard(src/routes.tsxin openedx/frontend-app-instructor-dashboard). - A caller passes those params:
resolveRouteByRole(gradebookRole, { courseId })in the instructor dashboard,resolveRouteByRole(instructorDashboardRole, { courseId })in gradebook. resolveRouteByRolereturnsisInternal ? generatePath(path, params) : path. A path in this site has its params filled; for anything else the params are ignored, with no warning, and the URL comes back unchanged. The TSDoc says so ("an external URL is returned as configured"), and a test pins it by passing{ courseId: 'c1' }for a role whose external URL ishttps://apps.example.com/profile/and expecting that URL back.ExternalRouteis a role and a URL. An external route written ashttps://lms.example.com/courses/:courseId/progresscomes back with the literal:courseIdin it.- The caller cannot tell which case it is in before it calls: who provides a role is a property of the site, not of the role.
- One exception follows from the same line: an external route written as a path (a single leading
/) is classed as internal byisInternalUrl, so its params are filled, and it is linked through react-router.
What the docs say
- The migration guide's URL Config changes presents the two as interchangeable: URLs "should now be expressed as part of the
appsconfig as route roles, or asexternalRoutes, and resolved in code viaresolveRouteByRole(). It substitutes route params, drops a trailing splat, and reports whether the result is a path in this site or an external URL". It does not say the substitution applies to one of the two only. - No ADR in
docs/decisions/covers route roles with params or external routes; 0013 mentions roles for the course bar'sprovides.
How it got here
- #320 added
resolveRouteByRole(closing #317 and #319) to replace logic two apps had each written by hand. Both substituted params into whatever the role resolved to, an external URL included: openedx/frontend-app-gradebook#627 calledgetUrlByRouteRole(instructorDashboardRole)?.replace(':courseId', courseId), and openedx/frontend-app-instructor-dashboard#246'ssrc/utils/routeByRole.tsranurl.replace(`:${name}`, value)for each param before it tested whether the URL was absolute. Neither had a test of an external URL with a param. - #320's description states the new behavior ("an external URL is returned as configured") and gives no reason; the PR has no review comments.
- react-router's
generatePath, which #320 uses for the substitution, does not take an absolute URL: on react-router 6.30.6,generatePath('https://lms.example.com/courses/:courseId/progress', { courseId })returnshttps:/lms.example.com/courses/<courseId>/progress, the//collapsed.
Where it bites
- Both call sites above keep a URL of their own for when the role resolves to nothing (
gradebookRoute?.url ?? data.gradebookUrl,dashboardRoute?.url ?? instructorDashboardUrl(courseId)), and that fallback is the only way either reaches a destination outside the site with the course in it. A site that declares an external route for one of those roles replaces the fallback with a URL that cannot name the course. - The shell's own
ProfileLinkMenuItemreaches a user's profile by appending/u/<username>to the profile role's URL, which works for an app route and an external route alike because the role's route takes no param: openedx/frontend-app-profile declares the role onprofileand serves the user's page from its childu/:username(src/routes.tsx). - Learning declares
org.openedx.frontend.role.courseOutline,courseDates,courseProgressandcoursewareon routes undercourse/:courseId, and its progress tab links to them by role (openedx/frontend-app-learning#2190). If #348 lets a site point one of them at an external route, the link the site gets has no course in it.
Questions
- Should a site be able to provide a role whose route takes params with an external route?
- If so, how does an external route say where the params go?
- Until then, where does an app author declaring a role, or an operator writing
externalRoutes, learn that params are dropped for an external URL? - Should the resolver report it when it is handed params it will not use?
- Lenguaje dominante
- TypeScript
- Estrellas
- 4
- Forks
- 13
- Merge medio
- 3 d 5 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openedx/frontend-base
-
Export `SkipLink` componentAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
openedx/frontend-base#330 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
openedx/frontend-base#327 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openedx/frontend-base#210 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
openedx/frontend-base#350 ·
-
A site cannot override an installed app's route for a role with an external routePosiblemente ocupada @arbrandes la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
openedx/frontend-base#348 · 1 asignado ·
Todos los issues de openedx/frontend-base
Issues similares
-
bug P3
Dificultad 1/5 Menos de una hora Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
feat(ai): add markdown checklist export and copy-to-clipboard button to ActionItemSynthesizer drawerAbiertoai enhancement feature feature-request good-issue L1 level 1 needs-review wocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
SatyamPandey-07/WorkSphere#8149 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement follow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
Client execution contract accepts a grant the code never takesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: client enhancement priority: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opensro-dev/opensro#3808 ·
Los mantenedores suelen responder en 1 día
-
bug ux
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
mithilp/keybuddies#66 ·