[WRONG BRANCH] fix(codex): enforce base variant storage limits - #353
[WRONG BRANCH] fix(codex): enforce base variant storage limits#353luvs01 wants to merge 1 commit into
Conversation
|
✅ Deterministic PR hygiene checks passed. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏳ DRAFT
What to do
Its title has been prefixed with |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e7ab4d746
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const normalized = normalizeBody(body.body); | ||
| if (utf8Bytes(normalized) > MAX_BODY_BYTES) { | ||
| return fail(ctx, "body_too_large", 400, `base variant exceeds ${MAX_BODY_BYTES} bytes`); |
There was a problem hiding this comment.
Enforce the limit on the complete stored variant
When a dashboard-session client supplies a large title, this check measures only body, while writeBaseVariant prepends the unrestricted title to the persisted Markdown file and the subsequent snapshot reads it back. A title approaching the 4 MiB management-request limit therefore bypasses the new 64 KiB storage restriction and can still produce and echo a multi-megabyte base prompt. Validate the title and/or measure the complete serialized variant before writing it.
AGENTS.md reference: src/AGENTS.md:L20-L20
Useful? React with 👍 / 👎.
Motivation
MAX_BASE_VARIANTScap.Description
idto refer to an existing variant insrc/codex/prompt-layers.ts, making the server-generated-ID path the only way to create new variants.MAX_BODY_BYTEScheck insrc/server/management/codex-prompt-routes.tsbefore calling the writer and reject oversized base-variant bodies.tests/codex-prompt-base-variants.test.tsandtests/codex-prompt-route.test.tsthat assert a caller-supplied (nonexistent) editidcannot create a variant and that oversized creates are refused.Testing
bun test tests/codex-prompt-base-variants.test.ts tests/codex-prompt-route.test.ts --timeout 10000and the updated cases passed.bun run typecheckand it succeeded.bun run privacy:scanand it succeeded.bun run test; the modified prompt tests passed within the suite but there remain unrelated existing failures elsewhere in the suite (not introduced by these changes).Codex Task