Repository navigation
fix: deny retained stream output and raw email history - #1294
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | The PR still contains the stream-guard code that the prior run flagged. Its cumulative diff against main (d267626 → 67092e7) adds 19 production lines to app/lib/workflows/runAgentStep.ts. The late… |
Before merge: - Extract the duplicated void Promise.resolve(result.finishReason).catch(() => {}); void Promise.resolve(result.response).catch(() => {}); pair into one named helper, for example silenceProviderPromises(result). Call it fr… |
Full details: Solid & Clean Code
-
Explanation
The PR still contains the stream-guard code that the prior run flagged. Its cumulative diff against main (d267626 → 67092e7) adds 19 production lines to
app/lib/workflows/runAgentStep.ts. The latest commit (67092e7) changes only the email adapter, its test, and the README, so the stream code is unchanged from the failing run. Verified findings: 1. DRY violation (introduced by this PR). The pairvoid Promise.resolve(result.finishReason).catch(() => {});andvoid Promise.resolve(result.response).catch(() => {});appears twice. The new refusal branch has it at lines 254–255. The existing user-stop branch has it at lines 272–273. The PR copies the block instead of extracting a helper. The custom check requires "Avoid copy-paste programming" and "Extract repeated patterns into abstractions." 2. SRP and function length (worsened).runAgentStepspans lines 114–293, about 180 lines. The PR adds a privacy-refusal capture (outputRefusaland theassertOutputclosure) and a refusal-specific rethrow path inside it. The check says "Look for functions longer than 20 lines" and "Avoid … functions with multiple responsibilities." The PR adds responsibility to a function that already breaks that rule. 3. Implicit control flow. A mutable outerlet outputRefusalis set inside a closure and read later incatch. The check favors "explicit over implicit behavior." The guard could be a named, separate function. The email change is clean. It adds three lines, reuses the existingassertNoRetainedFieldModelInputhelper, and does not duplicate logic. It does not cause the failure. The prior run's required resolution was not applied. No helper was extracted for the duplicatedPromise.resolvepair. The refusal guard was not moved to its own module. Because the prior failure is not addressed, this run cannot PASS. This verdict covers code-quality criteria only. It does not assess security behavior.Resolution
Before merge: - Extract the duplicated
void Promise.resolve(result.finishReason).catch(() => {}); void Promise.resolve(result.response).catch(() => {});pair into one named helper, for examplesilenceProviderPromises(result). Call it from both the refusal branch and the user-stop branch. - Move the refusal guard (outputRefusalplusassertOutput) into a dedicated module with an explicit, named function.runAgentStepshould only call that function. - Consider moving post-stream cleanup and error classification out ofrunAgentStep. This can be a follow-up if the security fix must land first. Record that follow-up explicitly.
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37f7c6b34b
ℹ️ 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".
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Turn on auto-fix | Re-trigger cubic
Structured retained output had two disclosure paths: runAgentStep wrote marked tool-output parts before the workflow's returned-message check, and email history adaptation removed markers while preserving sibling private text before agent.generate.
The step now checks each UI stream part before acquiring its writer and checks accumulated onFinish output before capture. A refusal remains fatal across cancellation races, so withheld output cannot return as an ordinary aborted result for persistence. Existing poller/provider abort cleanup and workflow ownership of stream closure remain intact.
Email's getEmailRoomMessages now checks raw stored content before text-only adaptation. It denies the whole generation before agent.generate, preserving room query ordering and authenticated account/organization context. The existing inbound handler's generic error response is unchanged. Addresses #1294 (comment).
Base main
d26762603d2881875766e078f37561ff18424f9fincludes merged #1293. Current head67092e7da7e84da540cb814d9db9b11b357d5628, treeddde012fac2bdc82424228c18e71f88f040a180b. Full delta against main: five files, 22 added production lines (19 stream guard +3 email adapter), tests and README. Ordinary composition merge4719d97c preserved reviewed37f7c6b3 tree; this successor adds only email adapter/test/README changes. Stream production and tests remain byte-identical to OAuth455-reviewed37f7c6b3; that evidence remains attributed to its original head.Validation: email failing-first 2 failures/2 passes, then4 actual generateEmailResponse caller tests pass with real adapter and synthetic DB/agent seams. Cases cover part/metadata marker plus sibling text, whole-call static FatalError, zero agent.generate/footer room lookup, unchanged source data and room/account context, and ordinary text/HTML history behavior. Full lint and diff checks pass. No broad or stream-suite rerun. Prior stream qualification at37f7 remains 31 focused tests plus final8 stream tests and independent synthetic SDK/cancellation review. Whole-repository tsc previously failed on unrelated tests/dependencies, no changed-file diagnostics; not claimed green. Exact-head CI/independent email closure pending.
No real email sending, tool/provider/account/history reads, network, SQL, browser, spending or activation. Tests use synthetic seams only. No positive authority, inference from serialized/unmarked data, or retraction of independently emitted prose. Stream guard cannot prevent an operation that already produced its output. Both paths reuse the existing reserved-family recognizer and redacted nonretrying FatalError. Root owns final review, merge and release.