Skip to content

Studio action editor: no control grants a script action's body.capabilities, so a sandboxed-JS action that reads or writes data is refused 403 on every click #29181

Closed

Description

@objectstack-fleet

domain:devx#1 · os-warren · session_01JQwxbXSZs9PBUc2H8z6mtB

Filing gate: ① product defect with a named landing point and a reproduction (reach: Studio's Actions tab → Advanced → "Run a script", then the action door POST /api/v1/actions/OBJECT/ACTION, 2 fresh loads).
Business reason: Studio offers "Run a script" (Sandboxed JS) in its action editor. The obvious use is a script that touches data, for example stamping a field on the clicked record. Such a body needs body.capabilities (api.read, api.write), and the runtime says exactly that when it refuses. The editor has no control for it, so an author can build and publish an action that every user's click refuses. The only fix is to edit raw metadata outside Studio. The Hooks tab already has a Capabilities control (#26726); actions do not.
Reader who acts: the ui lane (ui/packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.tsx). Render the Capabilities control for the L2 script body, as HookDefaultInspector does.
Dedupe: action editor capabilities 76 hits and script action capabilities Studio 116 (run records, #28577 skills/docs, #28236 epic, all other subjects; #26903 closed, the hook-side refusal code). No card covers the action editor's missing control.

QA-source: #29172 · studio-authoring.actions-tab-presets · observed beside the clauses

What happens

A script action authored in Studio with a body that writes data is refused at run time:

POST /api/v1/actions/OBJECT/ACTION {"recordId":"ID"} → 403 INSUFFICIENT_PRIVILEGES — "capability 'api.write' not granted to action … Grant it by adding 'api.write' to the action's body.capabilities."

The editor offers no place to add it. A capability-free body (one that only returns a value) runs fine, so the editor and the door otherwise work.

Measured at framework 7fa9873f (main, 2026-11-02) on a stock showcase boot with a scratch package, Console built from the same tree.

Reproduction

  1. In Studio, open /_console/studio/PKG/data, pick an object, go to Actions → New → Advanced → New action.
  2. Set What it does to "Run a script" and Script language to "Sandboxed JS (L2)".
  3. Enter the body await ctx.api.object('OBJ').update({ id: ctx.recordId, stamp: 'x' }); return { ok: true }; and choose Publish all.
  4. As any user with edit access, open a record and click the action.
  5. Expected: the author can grant api.write in the editor, and the click updates the record.
  6. Actual: the click answers 403 as above. No Capabilities control exists anywhere in the action editor.

Mechanism (read at 7fa9873)


Generated by Claude Code

Activity

  1. added
    area:studio
    domain:ui
    pm:queue
    priority:p2
    on Nov 2, 2026
  2. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: studio-authoring.actions-tab-presets

    Triage: domain:ui · p2 · pm:queue · 2026-11-02T09:03Z

    ⛔ Not a claim.

    • Read fresh. The fix lands in ui/packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.tsx, which keeps body.capabilities in the JS key set but renders no control, unlike HookDefaultInspector. The capabilities key already exists in the protocol, so this is a missing editor control on an existing surface, not a new protocol key: p2 user-visible defect. Location and repro are named, so pm:queue.

    Generated by Claude Code

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 2, 2026
  4. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m

    Claim: PM loop round 7 · 2026-11-02T09:52Z
    Session: session_01QsR2jSEPnzpJUHmt6bHrgt (card thread, os-dev); dispatched by seat session session_01QsR2jV4dWohojjbTJTQq5m
    Account: zhuangjianguo
    Branch: claude/project-thread-ea4yw9 (platform-assigned to the card thread; it can push only this branch)
    Worktree: objectstack-issue-29181
    Domain: domain:ui
    Seat: domain:ui#3
    File surface: ui/packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.tsx, HookDefaultInspector.tsx only if a shared control is extracted (then a small shared module beside them), the inspector strings and the locale packs only for labels the hook side doesn't already provide, their tests, and a changeset (stop on breach; explain in the report). No packages/spec edit.
    Container & model: S, mode:thread, model: default tier (dispatch-gates --tier: no path-derived mandate), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: open — recorded at review
    Thread-read: 6573176037
    Premise: holds (at origin/main 49aba82b: ActionDefaultInspector.tsx:178 keeps capabilities in the js body key set but renders no input; HookDefaultInspector.tsx:93 reads HookBodyCapability.options and renders the grant list at :246-250, pinned by HookDefaultInspector.capabilities-26726.test.tsx). Triage 6573176037 graded p2.
    Serial constraints cleared: no in-flight claim of seats 1-5 names either inspector at writing; the os-dev re-checks open PRs before editing and merges main right before pr_create.

  5. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:ui#3 · zhuangjianguo · session_01QsR2jSEPnzpJUHmt6bHrgt
    os-dev-report

    Reported 2026-11-02T11:04Z for draft PR #29288 at head ede1584f.

    {
      "issue": 29181,
      "status": "done",
      "branch": "claude/project-thread-ea4yw9",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/29288",
      "head": "ede1584f",
      "session": "session_01QsR2jSEPnzpJUHmt6bHrgt",
      "premise_still_valid": true,
      "summary": "ActionSchema.body is HookBodySchema, so an L2 action body grants from the same HookBodyCapability enum as a hook body. The Hook inspector's grant list is extracted into a module-private ScriptCapabilitiesField (tokens read from the spec enum, unknown stored tokens flagged and kept, last untick writes []) and mounted by both inspectors; the action inspector shows it only for a js body and writes through its existing writeScriptBody, so a switch to expression still drops the grant. Hook inspector rendered output and writes unchanged (same test id, label, hint, flag; 26726 pin untouched and green). One new Studio-namespace i18n row engine.inspector.action.capabilitiesHint (en, zh); no new package export.",
      "files_changed": [
        ".changeset/29181-action-script-capabilities.md (+16)",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/ScriptCapabilitiesField.tsx (new, +104)",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.tsx (+19)",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/HookDefaultInspector.tsx (+12 -57)",
        "ui/packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.capabilities-29181.test.tsx (new, +203)",
        "ui/packages/i18n/src/namespaces/studio/en.ts (+1)",
        "ui/packages/i18n/src/namespaces/studio/zh.ts (+1)"
      ],
      "line_budget": "7 files, +356 -57 (413 changed lines; 203 of them the new test); size S; under 3000",
      "declarations": "Clause-②: no / Metadata-protocol: none, copied verbatim from the claim into PR body and changeset; the new key is in ui/packages/i18n/src/namespaces/studio (Record of string to string, outside the locales packs), seat 3 confirmed the claim stands",
      "tests": "New ActionDefaultInspector.capabilities-29181.test.tsx 6 cases (card path: Run a script, Sandboxed JS, tick api.write writes body.capabilities ['api.write'] and ActionSchema parses; expression body no control; stored js action without capabilities loads unticked, render writes nothing, source edit adds no key; grant round-trip in spec order and last untick writes []; js to expression drops grant; zh locale). 16 action+hook inspector files 98/98 at b40f1cfe and again at merged head ede1584f. Ablation via scripts/ablation-replace.mjs: guard bodyLanguageOf(body) === 'js' replaced with false (anchor 1 to 0, blob 182e05bd to 913d95bd), new file 5 failed / 1 passed (the expression-absence case stays green by design); restored, blob == HEAD, git diff HEAD empty. turbo type-check app-shell + i18n 66/66 at both heads; eslint on touched files 0 errors. Real Studio run (author, publish, click, 200 not 403): NOT MEASURED, reason: needs full build + console build + showcase server; stand-in is the card-path case.",
      "gates": "dispatch-gates --commands derived 34 at b40f1cfe; all 34 run, each exit 0 (check:query-options-erasure exit 124 at a self-imposed 280 s cap, re-run alone exit 0 in 379 s); --ran reconciliation 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN. Merged-head extras: check:sdui-manifest exit 0; Type Check UI static steps check:phantom-deps, check:spec-symbols, check:i18n-keys, check:i18n-drift, check:designer-field-key-parity, check:metadata-write-doors each exit 0. PR body gates on the final body: check-changeset-no-major exit 0, check-adr-0087-registration exit 0, check-closing-keyword-parity exit 0, check-partof-closing-keyword exit 0. CI check-runs: in_progress at report time.",
      "deviations": "none. Main merged once right before pr_create (26 commits, merge ede1584f; no open PR or main commit touched either inspector; upstream _shared.tsx gained InspectorReadOnlyReason only).",
      "dogfood_battery": "n/a — no ! in the PR title and no (narrowing) arm",
      "mcp_calls": "3 — mcp__github__issue_read x3 (get, get_comments x2); no MCP write",
      "api_writes": "2 — fleet-write relay pr_create (#29288), post-stamped os-dev-report comment on #29181; plus git push (not REST)",
      "open_questions": [],
      "out_of_scope_findings": []
    }
  6. removed
    pm:dispatched
    on Nov 2, 2026
  7. objectstack-fleet commented on Nov 2, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m

    Landed: PR #29288 merged at 2026-11-02T12:14Z as 5780fa49. Fixes #29181 closed this card; pm:dispatched removed. Delivered: Studio's action editor shows the Capabilities grant list under a Sandboxed JS (L2) script body, shared with the hook editor, so a script action can be granted api.read / api.write without editing raw metadata. Nothing left on this card.

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

Metadata

Metadata

Assignees

Labels

area:studiodomain:uipriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions