Skip to content

web: toolbar USB export sends a string source again - #45

Merged
vynulldev merged 1 commit into
mainfrom
fix-export-source
Oct 3, 2026
Merged

vynulldev merged 1 commit into
mainfrom
fix-export-source

Conversation

@vynulldev

Copy link
Copy Markdown
Owner

What & why

Shoutout to @kayrozen (#44) for finding and reporting this bug!

Exporting from the library toolbar failed with 400 invalid JSON: json: cannot unmarshal object into Go struct field .source of type string, while exporting via the bulk-select bar worked.

openExportModal(presetSource, presetLabel) gained its preset parameters for the bulk-select bar, but the toolbar button was wired as exportBtn.onclick = openExportModal - so the click EVENT arrived as presetSource, and the export request's source field went out as a serialized event object instead of a string. Every toolbar export (collection or a selected playlist) has been broken since the bulk-select feature landed; the bulk path passes a real string and kept working.

The handler now calls openExportModal() through a closure, and the modal coerces any non-string presetSource to null so future direct handler wiring can't regress the request body again. Verified headless with Playwright: clicking the toolbar button now issues /api/export/preview?source=all (previously source=[object PointerEvent]).

Web UI only; no server-side change.

Hardware testing

  • Tested on: N/A: web UI request construction only; no deck-facing change. Verified headless (toolbar click → string source).

Checklist

  • go build ./..., go vet ./..., and go test ./... pass
  • gofmt -l . is clean
  • New source files carry an SPDX header (GPL-3.0-or-later) (n/a, no new files)
  • Tested on real hardware (deck + firmware noted above), or this change doesn't affect deck behaviour
  • I agree my contribution is licensed under the project's GPLv3

Wiring openExportModal directly as the toolbar button's click handler
passed the click EVENT as its presetSource parameter (added later for
the bulk-select bar), so the export request's source field went out as
a serialized event object where the API expects a string - every
toolbar export (collection or playlist) failed with 400 "cannot
unmarshal object into Go struct field .source", while the bulk-select
bar, which passes a real string, worked. Reported from the field with
exactly that asymmetry, which was the tell.

The handler now calls openExportModal() through a closure, and the
modal coerces any non-string presetSource to null so future direct
handler wiring can't regress the request body. Verified headless: the
toolbar button's preview request goes out as source=all again.
@vynulldev
vynulldev marked this pull request as ready for review October 3, 2026 00:25
@vynulldev
vynulldev merged commit 94fbd24 into main Oct 3, 2026
1 check passed
@vynulldev
vynulldev deleted the fix-export-source branch October 3, 2026 17:53
@vynulldev vynulldev linked an issue Oct 3, 2026 that may be closed by this pull request
2 tasks done
@vynulldev vynulldev mentioned this pull request Oct 3, 2026
2 tasks done
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.

Export playlist bug

1 participant