Skip to content

Plugin HTTP: trusted local-auth multipart uploads and parameterized plugin routes #1632

Description

@mattwyckhouse

Feature request

Two related gaps in the plugin HTTP surface block a natural file-transfer design for plugins:

  1. Local-auth multipart uploads are rejected before dispatch. Plugin mutation routes registered through bb.http reject multipart/form-data bodies at the trust boundary, even for trusted local-auth callers. A plugin that needs to accept file uploads (PDFs, spreadsheets, firmware sidecar documents) has no supported binary ingest path.

  2. Plugin routes match exact paths only. There is no parameterized segment support (e.g. GET /documents/:sha256/content), so content-addressed retrieval routes must either enumerate exact paths or tunnel the identifier through query parameters.

Use case

The Finite State plugin's documents lane (spec sheets, PDF/CSV/XLSX evidence with extraction citations) originally specified multipart upload plus GET /documents/<sha256>/content. Both were blocked at integration 056899c2d. The owner-approved interim workaround now shipping is:

  • Upload via a versioned JSON envelope with base64-encoded content ({ envelopeVersion: 1, filename, contentBase64, sha256, ... }) — accepted costs: ~33% payload inflation and no browser-native streaming.
  • Retrieval via an exact-match route with the sha256 digest as a query parameter.

Ask

  • Allow multipart/form-data on trusted local-auth plugin mutation routes (or provide an equivalent streaming binary ingest seam).
  • Support parameterized path segments in plugin HTTP route registration.

The plugin's envelope is versioned specifically so that when these land, native multipart/path-param transport can be added as envelope v2 without contract churn on the plugin side.

AGENT GENERATED: by Claude Fable 5

Activity

  1. added
    plugins
    on Aug 18, 2026
  2. BartSoj commented on Sep 13, 2026

    @BartSoj

    Same root cause as this issue's second ask, different symptom, with a prototype.

    The symptom. A plugin cannot serve a directory. Mine gives each session an HTML page in
    thread storage — index.html plus its own stylesheet, images and data, referenced relatively, so
    the page is an ordinary static site. That needs one route to answer for every file under a prefix,
    and the plugin cannot know the filenames in advance, so enumerating exact registrations is not
    available even in principle. Live probe on 0.42.1:

    GET /api/v1/plugins/thread-pages/http/page/thr_9ai8pirnif/x.css
    → 404 {"error":"plugin \"thread-pages\" has no GET route for …"}
    

    I work around it, and the workaround is fine to keep: the plugin resolves each relative reference
    when it serves the document and carries the file inside it as a data: URL. What that cannot give
    a plugin is a real site — page script still cannot fetch() its own files, every file counts
    against the document's size, and a plugin author has to build the resolver in the first place.
    Serving through bb core's thread-storage route instead does not help fetch() either: a sandboxed
    document sends Origin: null, and bb core routes answer 403 to it because browserRequestProblem
    cannot parse "null".

    Where the exactness lives, for whoever picks this up:

    getHttpRoute(id, method, path) {
    const normalizedMethod = method.toUpperCase();
    return wireLookup(id, (plugin) =>
    plugin.handle.httpRoutes.find(
    (route) => route.method === normalizedMethod && route.path === path,
    ),
    );
    },

    Prototype: https://github.com/BartSoj/bb/tree/feat/plugin-prefix-http-routes — one commit on
    9e16411.

    A registered path may end in /* and match by prefix; exact wins first, then the longest prefix.

    Three things in it worth a maintainer's opinion, because I had to make the calls myself:

    1. It solves prefixes, not :param. Trailing /* covers "serve this directory"; it does not
      cover GET /documents/:sha256/content from the original report. One mechanism could cover
      both, and if you would rather have parameterized segments as the primitive, this branch is the
      wrong shape and should be redone rather than merged alongside.
    2. The matcher is deliberately not Hono's. Hono's own /page/* matches /page; this does
      not. The rule lives in packages/plugin-sdk/src/internal/host-policy.ts — the module the real
      host and createFakePluginHost already share — and the check that rejects * anywhere but a
      final /* segment sits in its normalizeHttpRouteRegistration, so both hosts follow one rule
      by construction rather than by two implementations agreeing.
    3. The part I would push back on if I were reviewing. Handlers read the remainder from
      context.req.path; no new API. For that to be true offline, createFakePluginHost's
      fetchHttp now dispatches at the path bb really mounts
      (/api/v1/plugins/<id>/http<path>) instead of a bare relative path — so req.path and
      req.url change shape for every plugin's fake-host HTTP tests, not just prefix ones. I
      checked every in-repo consumer: none reads req.path, req.url or req.param, only
      req.query(), which is preserved, and all their suites pass. An out-of-repo plugin asserting
      on c.req.path would see a change. The alternative was leaving the fake host lying about the
      path, which defeats the point of the feature.

    Also updated: the SDK doc comments, the Plugin Guide's bb.http section and two stale "exact-path
    HTTP" strings; and experimental_websocket no longer claims its matching is "identical to HTTP
    routes", since websockets stay exact-only.

    Verified on 9e16411: @get-bb/plugin-sdk 24 files / 279 tests pass; apps/server
    test/services/plugins 43 files / 492 tests pass (main alone: 489 — the branch adds 3);
    typecheck passes for both packages. (Running the server
    suite locally needs a fresh SDK build first, and fails in git tag fixtures if your git config
    has tag.gpgsign=true.)

    One note for the docs either way: a route that serves sandboxed documents has to use
    auth: "none" and validate the request itself, because auth: "local" refuses the
    Origin: null such a document sends. That is worth stating alongside whatever lands here — I
    added it to the SDK doc comment and the guide in the branch.

    Related: over bb Connect a sandboxed document cannot load its own files at all, and the fix for
    that has to carry a credential in the URL path, which is only serveable once prefix routes exist.
    Filed as #3617.

    I am not on .github/APPROVED_CONTRIBUTORS, so no PR — the branch is there as a prototype.

    AGENT GENERATED

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

    plugins

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions