Skip to content

bug(slm): File Browser downloads binary files as decoded text, corrupting them #21029

Closed

Description

@mrveiss

Summary

The SLM File Browser downloads every file as decoded text. Binary files (images, archives, PDFs) are corrupted on download.

Evidence (verified on origin/main by reading code; not reproduced in a running system)

  • autobot-slm-frontend/src/views/tools/admin/FileBrowserTool.vue lines 142-151 (downloadFile): const content = await api.readFile(filePath), then new Blob([content], { type: 'application/octet-stream' }), then an anchor click.
  • autobot-slm-frontend/src/composables/useAutobotApi.ts lines 842-847: readFile calls GET /files/read?path=... and returns response.content typed as string.
  • autobot-backend/api/files.py, route /read (admin_read_file, around line 1215): target.read_text(encoding="utf-8", errors="replace") returns {"content": content} (AdminFileReadResponse, autobot-backend/api/schemas_system.py:325). Non-UTF-8 bytes are replaced with U+FFFD on the server, so the original bytes never reach the browser.
  • No raw or binary route serves the admin browser's paths. The existing GET /api/files/download/{path} (autobot-backend/api/files.py:608) is scoped to the sandbox through validate_and_resolve_path. Whether it can serve admin paths is unverified.

Impact

Every binary file downloaded through File Browser is corrupted. Non-UTF-8 text is altered as well. Whole files also travel as JSON strings.

Acceptance criteria

  • Downloads fetch raw bytes: through an existing raw route if one can serve admin paths, otherwise through a streamed route.
  • Downloads save with the kit's saveBlob / saveResponse.
  • A test with a binary payload (including bytes that are invalid UTF-8, such as 0x89 0x50 0x4E 0x47 and 0xFF 0x00) shows the bytes are preserved end to end.

Related

Activity

  1. added
    bugSomething isn't working
    area: frontend-unificationWave 4 · cluster B — Frontend unification & design system
    phase:M4.6Shared primitives in one place
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 7, 2026
  2. github-actions commented on Nov 7, 2026

    @github-actions
    Contributor

    needs-structure cleared: goal milestone, matching phase label and native parent (or sub-issues) are all present (#19522).

  3. removed
    needs-structureMissing goal milestone, matching phase label or native parent (#19522)
    on Nov 7, 2026
  4. mrveiss commented on Nov 7, 2026

    @mrveiss
    OwnerAuthor

    Structure set per maintainer decision (2026-11-07): milestone M4, phase:M4.6, parent #20770.

  5. github-actions commented on Nov 7, 2026

    @github-actions
    Contributor

    Landed in #21092, merge 26dd86da00

  6. 11 remaining items

  7. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    Landed via the merge train (#21333, merge 19ebd20488)

  8. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    Landed via the merge train (#21349, merge c5a3f23f92)

  9. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Closed with proof of implementation -- landed via #21087, train #21349, merge c5a3f23. Gate 2: check-issue-close-refs.sh 21029 -> clear.

    • "Downloads fetch raw bytes: through an existing raw route if one can serve admin paths, otherwise through a streamed route." -- met (code): autobot-backend/api/files_admin_raw.py:47 (admin-only router), :77 (_validate_admin_path, same validator as /read), :104-138 (StreamingResponse, bytes unmodified), mounted at core_routers.py:509.
    • "Downloads save with the kit's saveBlob / saveResponse." -- met (code): autobot-slm-frontend/src/composables/adminFileDownload.ts:14,25 (saveBlob(await response.blob(), filename)); FileBrowserTool.vue:145 calls it.
    • "A test with a binary payload (including invalid UTF-8 such as 0x89 0x50 0x4E 0x47 and 0xFF 0x00) shows the bytes are preserved end to end." -- met (code), in two halves: backend files_admin_raw_download_21029_test.py:20,70 (byte-exact), frontend adminFileDownload.test.ts:13,48 (saved bytes unchanged). Both passed in the train's CI run; no test spans server and browser together.

    Not asserted: behaviour in a running browser/host (not an AC). Ratchets moved with it: hand-rolled save PIN 5, reach floor 421.

  10. mrveiss commented on Nov 20, 2026

    @mrveiss
    OwnerAuthor

    Closure audit against main 13685f3: closed as completed, work on main, but the 3 ACs are still unticked in the body. Evidence: autobot-backend/api/files_admin_raw.py (admin-only raw route), autobot-slm-frontend/src/composables/adminFileDownload.ts:14 saves via the kit's saveBlob, adminFileDownload.test.ts:8 uses an invalid-UTF-8 payload. Boxes left for the owner to tick.

  11. mrveiss commented on Nov 20, 2026

    @mrveiss
    OwnerAuthor

    ACs ticked with evidence on main: AC1 raw admin route autobot-backend/api/files_admin_raw.py; AC2 autobot-slm-frontend/src/composables/adminFileDownload.ts:14,25 saves via the kit's saveBlob; AC3 invalid-UTF-8 binary payloads in autobot-backend/tests/files_admin_raw_download_21029_test.py and adminFileDownload.test.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions