Conversation
E2E tests hit real Upstash APIs and log() wrote full request/response bodies to stderr, which CI captured into public logs, leaking QStash and Redis tokens. Disable logging under NODE_ENV=test, and redact secret-bearing fields (token, rest_token, password, etc.) from all log output as a backstop even when logging is enabled.
…race - qstash.test.ts: clear the shared QStash user cache and reset config.readonly in beforeAll so it can't reuse read-only users cached by readonly.test.ts (whose token field is empty), which broke 'lists schedules (eu)'. - box.test.ts: poll the snapshot list until it leaves the 'creating' state before deleting, avoiding a 409 'Snapshot is still being created'.
There was a problem hiding this comment.
Pull request overview
This PR extends readonly Upstash API key support to allow QStash + Workflow read operations by wiring through the per-region read_only_token returned by the Upstash API, while keeping write tools hidden/blocked.
Changes:
- Add
read_only_tokento QStash user typing and update QStash credential selection to chooseread_only_tokenvstokenbased on readonly mode (with an explicit missing-token guard). - Mark QStash/Workflow read tools as
readonly: trueso they remain available when the server filters tools for readonly keys; update readonly/QStash tests accordingly (including cache reset between suites). - Add test-runner log suppression + secret redaction utilities (with unit tests), plus improve Box snapshot E2E stability by polling until snapshots are ready before deletion.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/qstash/workflow.ts | Marks Workflow log/DLQ read tools as readonly: true so they’re available under readonly keys. |
| src/tools/qstash/utils.ts | Uses read_only_token in readonly mode; removes the previous hard-throw that blocked QStash entirely in readonly mode. |
| src/tools/qstash/types.ts | Adds read_only_token to QStashUser. |
| src/tools/qstash/qstash.ts | Marks QStash logs/DLQ/schedules list/get tools as readonly: true. |
| src/tools/qstash/qstash.test.ts | Forces full-access mode and clears shared QStash token cache to avoid cross-test contamination. |
| src/tools/box/box.test.ts | Adds snapshot readiness polling before deletion to reduce 409 flakiness; adjusts timeouts/formatting. |
| src/readonly.test.ts | Updates expectations: QStash/Workflow read tools are available in readonly mode; adds a publish rejection check. |
| src/log.ts | Disables logging under tests and adds defense-in-depth redaction for sensitive keys. |
| src/log.test.ts | Adds unit tests for log-argument redaction behavior. |
| README.md | Documents readonly key behavior for QStash/Workflow reads and adds local smoke-test instructions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+44
to
+56
| function redactValue(value: unknown): unknown { | ||
| if (Array.isArray(value)) { | ||
| return value.map((item) => redactValue(item)); | ||
| } | ||
| if (value && typeof value === "object") { | ||
| const out: Record<string, unknown> = {}; | ||
| for (const [key, val] of Object.entries(value)) { | ||
| out[key] = SENSITIVE_KEYS.has(key.toLowerCase()) ? REDACTED : redactValue(val); | ||
| } | ||
| return out; | ||
| } | ||
| return value; | ||
| } |
| body: "{}", | ||
| method: "POST", | ||
| }) | ||
| ).rejects.toThrow(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Read-only Upstash API keys previously exposed only Redis tools — all QStash and
Workflow tools were hidden and hard-errored. The Upstash API returns a
read_only_tokenper region for read-only keys (the full-access token is empty),which works on read endpoints and is rejected by QStash on any write. This wires
that token through so read-only keys can list QStash logs, DLQ, schedules, and
Workflow logs/DLQ.
Changes
types.ts: addread_only_tokentoQStashUser.utils.ts: remove the readonly hard-throw; selectread_only_tokenvstokenby mode in
getQStashCredentials, with a guard for a missing token.qstash.ts/workflow.ts: mark the read toolsreadonly: true(
qstash_logs_list/get,qstash_dlq_list/get,qstash_schedules_list,workflow_logs_list/get,workflow_dlq_list/get). Write tools(
publish,schedules_manage,workflow_dlq_manage) stay hidden.readonly.test.ts: replace "not available" assertions with live read-toolchecks and a write-rejection check.
README.md: note QStash/Workflow reads are available with readonly keys; Box is not.Testing
read_only_token, reads succeed (200),publish rejected (403).
bun test src/readonly.test.ts→ 13 pass / 0 fail. prettier + eslint clean.Notes