Skip to content

Web UI features fail over non-localhost HTTP origins: crypto.randomUUID unavailable in insecure context (session delete, file attach) #46168

Closed as not planned

Description

@nico2525nn

Summary

Multiple Web UI features break when the Web UI is served over a non-localhost HTTP origin (e.g., a Tailscale hostname http://hostname:49374): the app calls crypto.randomUUID() directly, which is only available in secure contexts, so the calls throw TypeError: crypto.randomUUID is not a function and the action silently fails. Verified for (at least) file drag-drop attach and session delete. Everything works over http://localhost / http://127.0.0.1 (trusted origins).

Environment

  • opencode version: 0.0.0-beta-18414 (v2/beta line)
  • Interface: Web UI via background service http://0.0.0.0:49374
  • Access: http://nico.tail194715.ts.net:49374 (Tailscale hostname, plain HTTP → isSecureContext: false)
  • Browser: Chrome

Reproduction

  1. Access the Web UI via a non-localhost HTTP hostname (e.g., Tailscale).
  2. Session delete: open a session → "その他のオプション" menu → "削除..." → confirm "セッションを削除".
    • Nothing happens: the dialog stays open, no DELETE request is sent, and the console shows Uncaught (in promise):
      TypeError: crypto.randomUUID is not a function
          at Object.remove (runtime-…:651)
          at M (route-…:81)   // session delete click handler
      
  3. File attach: drag a file onto the composer (the drop overlay appears) → the file is not added, nothing is uploaded; same crypto.randomUUID is not a function unhandled rejection.

Expected Behavior

  • Session deletion should complete (dialog closes, session removed) regardless of the origin used, including Tailscale/remote hostnames over plain HTTP
  • File attachments should be added to the composer on any origin

Actual Behavior

  • Both actions throw on crypto.randomUUID (insecure context) and never reach the server API
  • Verified successful on http://localhost:49374 (secure context) for both features — confirming the root cause is origin-dependent, not a server issue

Root Cause

The shipped (v2/beta) bundle calls crypto.randomUUID() directly in the affected code paths (delete mutation, attachment part id generation) without a fallback. crypto.randomUUID is defined only in secure contexts (HTTPS or explicitly trusted origins like localhost). The dev branch already has a guarded uuid() util with a fallback for insecure contexts (packages/app/src/utils/uuid.ts), which should be used in these paths.

Suggested fix direction

  • Replace bare crypto.randomUUID() calls in the app bundle with the uuid() util (fallback for insecure contexts), or otherwise ensure IDs are generated without requiring a secure context
  • Audit other crypto.randomUUID usages in the web UI for the same class of failure over remote HTTP origins

Notes

  • Affects remote/network access patterns (Tailscale, LAN hostnames) which are common for the v2 preview
  • Same-family failure observed previously for file drag-drop attachment

Activity

  1. github-actions commented on Aug 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. LoikStyle commented on Aug 31, 2026

    @LoikStyle

    Cross-reference: related but not a duplicate of #46419 / PR #46418.

    #46418 adds a fallback for crypto.subtle in packages/app/src/utils/draft-store.ts (blob ID generation for image attachments). Same root-cause class as this issue (crypto APIs unavailable on insecure origins), but crypto.randomUUID here is separate: the uuid() helper already falls back to random, while the direct crypto.randomUUID() call sites flagged here are outside my change.

  3. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed report and root-cause analysis!

    This was reported on an early beta build (0.0.0-beta-18414). In the released 2.x versions, both of the paths you describe already use the HTTP-safe uuid() helper (it falls back when crypto.randomUUID is unavailable or the page isn't a secure context):

    • session delete (packages/app/src/runtime/server/data.ts)
    • attachment IDs and upload paths (packages/app/src/composer/attachments/)

    Could you upgrade to the latest 2.x release (currently v2.2.0) and check whether session delete and drag-and-drop attach still fail over your Tailscale HTTP origin? If they do, please include:

    • the output of opencode --version
    • the exact console error and stack trace

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.

    Related issues about the same kind of insecure-origin failure, ordered by likelihood of overlap:

  4. nico2525nn commented on Oct 31, 2026

    @nico2525nn
    Author

    Verified fixed on opencode v2.2.1.

    Both paths from the original report now use the HTTP-safe uuid() helper (packages/app/src/runtime/persistence/uuid.ts), which falls back when crypto.randomUUID is unavailable or the page is not a secure context:

    • session delete: packages/app/src/runtime/server/data.ts uses uuid() for the remove mutation (no direct crypto.randomUUID remaining)
    • file attach: packages/app/src/composer/attachments/attachments.ts and destination.ts use uuid() for attachment IDs and upload paths

    Session delete and drag-and-drop attach now work over the Tailscale plain-HTTP origin. Closing as fixed. Thanks!

  5. opencodejr commented on Oct 31, 2026

    @opencodejr

    We haven't heard back, so we're closing this for now.

    This was reported on an early beta build (0.0.0-beta-18414). In the released 2.x versions, session delete and file attachments already use an HTTP-safe ID helper instead of calling crypto.randomUUID() directly, so these two failures should be gone. We were waiting to hear whether you still see them on a current 2.x release.

    If session delete or drag-and-drop attach still fails over your Tailscale HTTP origin on the latest 2.x, please reply with your opencode --version output and the console error, and we can reopen. Other features that fail on insecure origins are tracked in #55777 (sending prompts) and #59791 ("Open file"). Thanks again for the thorough report!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions