Repository navigation
Plugins: accept a file as base64 (#1727) - #1730
michielbdejong wants to merge 2 commits into
Conversation
An `accepts` entry takes an optional `as: "text" | "base64"`, text by default. With base64 the host hands over the file's exact bytes as `input.upload.base64`, with no charset detection; text mode still arrives as `input.upload.text`, so a plugin can tell them apart. - `as` is kept as declared: left out, it stays out of the serialized manifest, and an explicit "text" stays in, so no release id moves. - Both validators accept text or base64 and reject anything else with the same message, checked against new shared fixtures. - The server checks the upload is in a declared encoding and bounds it by its raw size: the decoded length for base64, not the string's. - The data browser picks the matching `accepts` entry and reads the file with `readUpload` from @tomic/lib. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts, both sides kept: - routes/IntegrationStore.tsx: the drive-apps count in nothingToDiscover next to #1742's gated catalog (marked releases and their refusals). - locales/en.po: the CatalogApps/FileImport/InstallationConnections entries next to #1742's PublicEndpoints entries; no duplicate msgids. - browser/lib/src/index.ts: #1730's plugin-upload exports next to #1742's checkGate, parsePluginRoutesStatus and requiresGate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pre-commit format check was skipped when this branch was committed with --no-verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge-risk triage (2026-09-28). This is a read-only review of this PR's own diff. The rule it applies: nothing that works today may break for existing users or clients, and new behaviour is added alongside the old. The stack is being rebased onto Verdict: SAFE Additive. Note: #1774 needs this PR's 🤖 Generated with Claude Code |
|
Closing as part of the plugin-host stack cleanup (Q-101): not needed by atomic-plugins now. See the inventory at #1726 (comment). The branch is kept, and pin candidates are unaffected. Closed by Claude (VPS coordinator) on behalf of Michiel. |
Closes #1727. Stacked on #1691 (
claude/plugin-accepts-file).What a plugin receives
An
acceptsentry takes an optionalas:input.upload(ctx.uploadinrun) carries the file in a field named after the declared encoding:asctx.upload"text", or left out{ name, mediaType, size, text }, UTF-8 with a Windows-1252 fallback (unchanged)"base64"{ name, mediaType, size, base64 }, the exact bytes, standard padded base64, no charset detectionsizeis the file's byte size in both cases. The sandbox hasatob, soatob(ctx.upload.base64)returns a binary string with one character per byte.Changes
server/src/plugins/manifest.rs,browser/lib/src/plugin-manifest.ts):asis optional and is kept exactly as declared. If it's left out, it stays out of the serialized form. If it's an explicit"text"(what Plugins: let a plugin accept a file and declare its destination (#1653) #1691 required), it stays in. Existing release ids don't change either way. Any other value, including"Base64"or64, fails in both validators withaccepts entries must be read \as` text or base64`.check_uploadinplugin_run.rs):textorbase64.acceptsentry must declare that encoding.maxBytesis checked against the raw size (for base64, the decoded length, not the length of the string). Invalid base64 is refused.@tomic/libgetsacceptForandreadUpload, which buildinput.upload.FileImport.tsxuses them in place of its owndecode. The UI doesn't change.acceptshas been added to the manifest v2 field list indocs/src/plugins/creating-plugins.md, and theDeclaredAccept/Acceptdoc comments describe the wire format.Tests
New fixtures only; no existing fixture file was edited. One existing case was renamed in
index.json: "v2 accepts only text" is now "v2 accepts an unknownas".testdata/plugin-manifest/:v2-accepts-base64.jsonis accepted and serialized withas.v2-accepts-default-text.jsonhas noasand is serialized without one.v2-accepts-as-upper-case.jsonandv2-accepts-as-not-string.jsonare rejected.release.rsaccepts_without_as_keeps_the_release_id: the default-text fixture and Plugins: let a plugin accept a file and declare its destination (#1653) #1691's explicit-"text"fixture give the same release id before and after parsing.js_runtime.rsa_base64_upload_reaches_the_plugin_byte_for_byte: bytes 0–255 go through the real sandbox, the plugin decodes them withatob, and every byte comes back.plugin_run.rs:maxBytes: 256, and 257 bytes fail.plugin-upload.test.ts:asistextor left out.acceptForpicks the right entry.Checks run:
cargo test -p atomic-server --lib -- plugins:: handlers::plugin_runcargo clippy -p atomic-server --all-targets(clean)browser/libvitest: 967 passeddata-browsertypecheck🤖 Generated with Claude Code