Skip to content

fix(billing): guard window.location.href against non-string payload#2464

Open
walidsaleh wants to merge 89 commits into
frappe:developfrom
walidsaleh:fix-lms-billing-object-object-url-clean
Open

fix(billing): guard window.location.href against non-string payload#2464
walidsaleh wants to merge 89 commits into
frappe:developfrom
walidsaleh:fix-lms-billing-object-object-url-clean

Conversation

@walidsaleh

Copy link
Copy Markdown

Fixes #2459

What

Billing.vue's onSuccess handler does window.location.href = data,
assuming data is a string URL. When the backend returns a non-string
payload (e.g. an error dict like {messages: [...]}), the browser
navigates to /lms/billing/course/[object Object] and the student
lands on a 404 page.

Why

The student gets stuck on a broken URL with no useful error message.
The actual cause is hidden because String({...}) produces
[object Object], which gives the operator no clue about what
went wrong.

How

Guard the assignment with a typeof === 'string' check. If data
is not a string, show a generic error toast via the existing
toast.error + __() pattern instead of navigating to a broken URL.

This is the second line of defense. The first line is the upstream
fix for get_payment_link (#2457), which now throws
ValidationError instead of returning a dict, so onError handles
the typical case. This onSuccess guard catches any future endpoint
that may return a non-URL payload.

pateljannat and others added 30 commits March 4, 2026 10:37
chore: merge 'main-hotfix' into 'main'
chore: merge 'main-hotfix' into 'main'
(cherry picked from commit 7d08a76)
chore: merge 'main-hotfix' into 'main'
chore: merge 'main-hotfix' into 'main'
chore: merge `develop` into `main-hotfix`
fix: course progress updated for scorm and video end event (backport frappe#2247)
(cherry picked from commit 71c13d6)
fix: prevent path transversals in lms (backport frappe#2274)
chore: merge 'main-hotfix' into 'main'
chore: merge `develop` into `main-hotfix`
…2282

fix: prevent unauthorised enrollments in paid courses (backport frappe#2282)
chore: merge `develop` into `main-hotfix`
(cherry picked from commit f244a6c)
raizasafeel and others added 29 commits May 12, 2026 14:09
perf: refactor course outline and lesson to use qb (backport frappe#2381)
…2377

fix: user roles are removed on uninstall (backport frappe#2377)
…2376

fix: timezone now renders for courses and batches (backport frappe#2376)
…2383

fix(quiz): exam submissions and scope check_answer (backport frappe#2383)
…2367

feat: add empty states to settings (backport frappe#2367)
…n-hotfix

chore: merge `develop` into `main-hotfix`
…-main

chore: merge main-hotfix into main
fix: system manager permissions are set properly on install (backport frappe#2399)
chore: merge `develop` into `main-hotfix`
…/main-hotfix-to-main-v2

# Conflicts:
#	lms/patches.txt
…ain-v2

chore: merge `main hotfix` to `main`
chore: merge `develop` into `main-hotfix`
chore: merge `main-hotfix` into `main`
Closes frappe#2459

Billing.vue's onSuccess handler does 'window.location.href = data'
assuming data is a string URL. When the backend returns a non-string
payload (e.g. an error dict like {messages: [...]}), the browser
navigates to '/lms/billing/course/[object Object]' and the student
lands on a 404 page.

Guard the assignment with a typeof check. If data is not a string,
show a generic error toast via the existing toast.error + __() pattern
instead of navigating to a broken URL.

This is the second line of defense. The first line is the upstream
fix for get_payment_link (frappe#2457), which now throws
ValidationError instead of returning a dict, so onError handles the
typical case. This onSuccess guard catches any future endpoint that
may return a non-URL payload.
@walidsaleh walidsaleh force-pushed the fix-lms-billing-object-object-url-clean branch from f772a4e to 91491e9 Compare June 13, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug] Student checkout redirects to /lms/billing/course/[object Object] when backend returns error (frontend assumes string URL)

4 participants