Repository navigation
fix(den-api): clamp config object projections to fit MySQL TEXT columns - #3640
Conversation
Oversized SKILL.md bodies made the derived search_text projection exceed the 65,535-byte MySQL TEXT cap; strict-mode MySQL/Vitess rejects the whole insert/update with errno 1406 and the routes surfaced HTTP 500. Clamp derived title/description/search_text on a code-point boundary. The immutable version keeps the full raw source (MEDIUMTEXT); only the derived projection is truncated. Fixes DEN-API-1K Fixes DEN-API-Z
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Photo roll — an-oversized-multibyte-skill-md-saves-cleanly-and-only-its-derived-search-projec — 0/0 frames passed · 5 facts✅ 0/0 frames passed · 5 facts · 5 expectations passed · 0 failed ℹ️ FACT — 1. An oversized multibyte skill can be createdPOST /v1/config-objects with a 120132-byte SKILL.md returned HTTP 201; pre-fix this failed HTTP 500 with errno 1406 (DEN-API-Z).
ℹ️ FACT — 2. An oversized multibyte version update savesPOST /v1/config-objects/:id/versions with a 200072-byte SKILL.md returned HTTP 201; pre-fix this failed HTTP 500 with errno 1406 (DEN-API-1K).
ℹ️ FACT — 3. Only the derived search projection is clampedconfig_object.searchText holds 60000 UTF-8 bytes: within the 60000-byte projection budget, under the 65535-byte MySQL TEXT cap, and cut on a code-point boundary.
ℹ️ FACT — 4. The stored SKILL.md source is byte-identicallatestVersion.rawSourceText round-trips all 200072 bytes of the update; clamping never touches the source of truth.
ℹ️ FACT — 5. Small skills keep their full projectionA compact skill's searchText remains the exact name/description/body join; the clamp only affects oversized values.
Roll created 2026-08-09T14:16:48.702Z · Source: |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (5aec1cf07dee6d64a6225603eabc999ff8d37ba0). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
…bjects on desktop Smoke health endpoint ran the image with DATABASE_URL pointing at 127.0.0.1 inside the container, so the DB was never reachable. den-api binds :8788, then Better Auth's oauth-provider seedResources queries oauthResource during createAuthContext and the unhandled rejection kills the process — so docker port never resolved and the failure surfaced as 'No such container'. Pre-existing on dev (verified by building the origin/dev image and reproducing the identical DrizzleQueryError) and on PRs #3648/#3640; dev pushes look green only because the step is gated on pull_request. Not fixed by suppressing the crash: better-auth caches the context promise (auth/base.mjs:8 initFn(options), awaited per request), so a rejected init stays rejected for the process lifetime. Swallowing it would yield a container that passes health checks with permanently dead auth, when crashing lets the orchestrator restart into a healthy state. The test premise was wrong, not the app. The den-api smoke now stands up mysql:8.4 on a dedicated network, waits for a real mysqladmin ping, applies the schema with the image's own bootstrap.js (the asset the preceding step already asserts exists), and only then boots den-api against it — so the smoke additionally proves migrations apply, including 0057. Containers are no longer --rm, so logs survive a crash and get dumped on failure. Other matrix images keep the original path. Also fixes Warden's third finding: the desktop parser rejected the new 'script' config object type, silently dropping saved scripts from the Connect inventory.
…sable, behind an org flag (#3645) * feat(codemode): vendor @openwork/codemode confined interpreter with input bindings Vendored from anomalyco/opencode@38e10eb (MIT; NOTICE + UPSTREAM.md record provenance and divergences). Drops the OpenAPI adapter. Adds a local divergence: CodeMode.execute({ bindings }) seeds read-only root-scope values through the plain-data boundary, enabling saved parameterized scripts. 244 upstream + bindings tests pass via bun test. * feat(den): execute_capability_script + saved script capabilities behind org flag - codemodeScripts org capability (metadata.capabilities, default off), wired like mcpConnections: admin routes, GET /v1/org, rollout helper. - /mcp/agent registers execute_capability_script only when enabled: builds a per-call tool tree (tools.den.<op> via invokeMcpOperation in-process + tools.<connection>.<tool> via executeExternalCapability, tool policy applied at build), runs the confined interpreter with host limits, and search_capabilities matches now carry scriptPath. - New 'script' config object type: executeMarketplaceCapability executes saved scripts with Ajv-validated typed input, least-authority tree restricted to declared requiredCapabilities, and fail-closed capability_unavailable (providerCallAttempted: false) when a declared tool is missing or policy-disabled. - codemode_run receipts for every run (source adhoc|plugin:<id>) + GET /v1/codemode-runs (admin: org-wide, member: own) with safe MCP tag. - drizzle migration 0057: codemode_run table + object_type enum value. * feat(den-web): Codemode scripts admin toggle + Script runs dashboard - den-admin-panel: codemodeScripts capability checkbox beside Connect. - New Script runs screen (nav gated by capabilities.codemodeScripts): status, truncated source, tool calls, duration, when. * test(evals): codemode-scripts voiceover spec + testkit fixes - codemode-scripts.slow.test.ts: the approved 7-frame narration as observable assertions — org flag gating, deterministic rail probes, a real model turn answering idle-workers as one script step, parallel cross-connection fan-out with witness proof, save through the capability rail, teammate discovery + typed re-run, receipts, dashboard vision check, and fail-closed tool-policy proof. - testkit: locally booted Den seeds DEN_BOOTSTRAP_ADMIN_EMAILS so specs can flip /v1/admin capabilities; MySQL probe honors OPENWORK_EVAL_MYSQL_URL instead of hardcoding 3306. * fix(codemode): close OAuth-review and prototype-pollution gaps, repair lockfile churn Warden findings on #3645: - buildExternalMcpToolTree listed tools for connections pending admin OAuth issuer review, constructing the OAuth provider (and possible token refresh) against a configuration an admin had blocked. Filtering is now the exported pure predicate isCodemodeEligibleConnection, which mirrors probeExternalMcpConnection: skip allDisabled AND oauthIssuerReviewRequiredAt. - restrictCodemodeToolTree used `tools[ns] ??= {}`, so a connection named __proto__ wrote a tool definition onto Object.prototype. Namespaces now reserve __proto__/constructor/prototype, and the tree is accumulated in Maps and materialized with Object.fromEntries (defineProperty semantics). CI repair — the earlier pnpm install churned the lockfile: - restored the xlsx CDN tarball integrity hash (ERR_PNPM_MISSING_TARBALL_INTEGRITY broke openwork-tests on both runners under --frozen-lockfile) - pinned codemode's acorn to 8.16.0, the version already resolved in the workspace, removing an unrelated 8.16.0 -> 8.18.0 bump; lockfile is now additions only (167/0, was 184/15) - reverted an unrelated msgpackr-extract allowBuilds entry; pnpm-workspace.yaml is now identical to dev - Dockerfile.den copies packages/codemode (den-api depends on it) Simplification: deleted buildCodemodeManifest, which was dead outside its own test — both tree builders already return their own manifest. * fix(deps): declare msgpackr-extract in allowBuilds effect -> msgpackr -> msgpackr-extract ships an optional native accelerator with a build script. Without an explicit allowBuilds decision, CI's `pnpm install --frozen-lockfile` fails with ERR_PNPM_IGNORED_BUILDS. msgpackr falls back to pure JS, so this is declared false rather than compiling native code in every CI run and image build. Reverting this in the previous commit was my error: it is a direct consequence of adding effect, not unrelated churn. * chore: trigger Warden analysis after draft to ready The PR was opened as a draft, so Warden skipped it and never re-analyzed the head that fixes its two findings (OAuth-review bypass, prototype pollution). Warden does not support the ready_for_review event by design — .github/workflows/warden.yml notes that draft-to-ready PRs get analyzed on their next push — so this empty commit is that push. * fix(ci): smoke den-api against a real migrated MySQL; accept script objects on desktop Smoke health endpoint ran the image with DATABASE_URL pointing at 127.0.0.1 inside the container, so the DB was never reachable. den-api binds :8788, then Better Auth's oauth-provider seedResources queries oauthResource during createAuthContext and the unhandled rejection kills the process — so docker port never resolved and the failure surfaced as 'No such container'. Pre-existing on dev (verified by building the origin/dev image and reproducing the identical DrizzleQueryError) and on PRs #3648/#3640; dev pushes look green only because the step is gated on pull_request. Not fixed by suppressing the crash: better-auth caches the context promise (auth/base.mjs:8 initFn(options), awaited per request), so a rejected init stays rejected for the process lifetime. Swallowing it would yield a container that passes health checks with permanently dead auth, when crashing lets the orchestrator restart into a healthy state. The test premise was wrong, not the app. The den-api smoke now stands up mysql:8.4 on a dedicated network, waits for a real mysqladmin ping, applies the schema with the image's own bootstrap.js (the asset the preceding step already asserts exists), and only then boots den-api against it — so the smoke additionally proves migrations apply, including 0057. Containers are no longer --rm, so logs survive a crash and get dumped on failure. Other matrix images keep the original path. Also fixes Warden's third finding: the desktop parser rejected the new 'script' config object type, silently dropping saved scripts from the Connect inventory. * fix(ci): pin the smoke MySQL image to an immutable digest Warden flagged mysql:8.4 as a mutable tag: a registry-side replacement would execute unreviewed code inside the PR workflow, sharing the smoke test's docker network. Pinned to the current multi-arch index digest (verified to contain linux/amd64 for CI runners, and confirmed to pull, boot, and pass the same mysqladmin readiness probe the step uses). Worth noting the tag had already moved: the digest cached locally from an earlier pull no longer matched the registry's 8.4, which is exactly the drift being closed.
Problem
Production Sentry issues DEN-API-1K (
POST /v1/config-objects/:configObjectId/versions) and DEN-API-Z (POST /v1/config-objects): saving a large SKILL.md makes the derivedsearch_textprojection exceed the 65,535-byte MySQLTEXTcap. Strict-mode MySQL/Vitess (PlanetScale) rejects the whole write withData too long for column 'search_text' (errno 1406, sqlstate 22001)and the route surfaces HTTP 500. Render logs for the failing request (req_01kzjrx744exs9vch9sbfeb4m8) carry the unredacted driver cause confirming errno 1406.Multibyte content makes this worse than it looks: French accents/em-dashes are 2–3 UTF-8 bytes and CJK is 3, so payloads far below 65,535 characters overflow the byte cap. Input validation allows
rawSourceTextup to 1 MiB, and the projection concatenated the entire body uncapped.Fix
projection-text.ts:clampUtf8Bytes(byte-aware, never splits a code point) andclampCodePoints; budgetsPROJECTION_TEXT_MAX_BYTES = 60_000,PROJECTION_TITLE_MAX_CHARS = 255.title/description/searchTextinderiveSkillProjectionandderiveProjection(covers create, version update, plugin bundles, GitHub connector imports) and the inline bootstrap join.raw_source_text(MEDIUMTEXT) keeps the full source — only the derived search projection is truncated.Verification (agent-first)
Spec:
evals/specs/config-object-large-skill.slow.test.ts— 5 claims: 120 KB multibyte create returns 201 (DEN-API-Z repro), 200 KB version update returns 201 (DEN-API-1K repro),searchText≤ 60,000 bytes cut on a code-point boundary,latestVersion.rawSourceTextbyte-identical (no user data truncated), small skill projection unaltered.195f8e0ac)OPENWORK_EVAL_APP_SPECS=1 OPENWORK_EVAL_MYSQL_URL=mysql://root:[email protected]:3316 pnpm --dir evals exec vitest run --config vitest.config.ts --project stack specs/config-object-large-skill.slow.test.tsexpected 500 to be 201(reproduces production)5aec1cf07)OPENWORK_EVAL_DAYTONA=1 OPENWORK_EVAL_REF=fix/config-object-searchtext-overflow OPENWORK_EVAL_APP_SPECS=1 infisical run --env dev --silent -- pnpm --dir evals exec vitest run --config vitest.config.ts --project stack specs/config-object-large-skill.slow.test.tsbun test test/config-object-projection-clamp.test.ts test/plugin-system-create-bundle.test.ts(ee/apps/den-api)tsc --noEmit -p ee/apps/den-api/tsconfig.jsonExecution lane: Daytona (available and used for the final verdict); local lane used for the red/green control. Verdict: Passed. Evidence tape published below.
Fixes DEN-API-1K
Fixes DEN-API-Z