Repository navigation
feat(cli): traces interface - #7763
kemaldotearth wants to merge 25 commits into
Conversation
…sign-the-cli-interface-for-traces # Conflicts: # apps/cli/src/cli/root.ts # apps/cli/src/command-internal/colors.ts
CLI benchmark (Lightweight Commands): no changes foundCommit
API calls: unchanged for all 9 commands. Binary size: 135.1 MB, up 24.0 KB from 135.1 MB. Details: timing ranges, API calls per command, slowest phasesTiming ranges
API calls per command
Slowest phasesNo command moved beyond noise, so there are no phase deltas. Comment |
There was a problem hiding this comment.
🤖 AI Review
CLI reference prose guidance: snapshot supabase/supabase@4da4e91 supplied to reviewers (advisory, not a style pass).
The PR adds the experimental supabase traces command. Both independent reviews were available. Their 23 findings resolve to 20 confirmed findings after merging three overlaps. The highest-severity finding is that deep traces can fail before any output is produced. The review also confirmed unsanitized span IDs in terminal output, misleading timing and completeness information, and four generated Fumadocs files whose source files are missing. The supplied next context shows no fundamental conflict. Verification included code inspection and focused Bun checks. The full CLI suite was not run because workspace dependencies were absent.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟠 MAJOR | apps/cli/src/commands/traces/traces.tree.ts:40 |
correctness |
codex | A sufficiently deep trace can overflow the call stack before the command produces text or structured output. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.render.ts:128 |
security |
claude+codex | Returned span IDs bypass terminal sanitization in the ID column and the first-error line. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.handler.ts:83 |
error-handling |
claude | A malformed --trace-id produces the generated client's schema error and is classified as an internal request-construction failure. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.handler.ts:43 |
timing |
codex | The command loses submillisecond precision before it orders spans or computes durations. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.handler.ts:49 |
timing |
codex | An unparseable span timestamp can make a present-day trace appear to start in 1970 and last decades. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.tree.ts:55 |
correctness |
codex | Cycle recovery can detach a span from its valid parent even when the span is outside the cycle. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.tree.ts:40 |
correctness |
codex | Repeated span IDs can be counted twice or silently dropped depending on their parentage. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.handler.ts:119 |
terminal-output |
codex | The default text output presents duration and counts without indicating that they describe a partial trace. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.render.ts:122 |
terminal-output |
codex | Long labels or deep indentation can hide the error and slowest-span markers in terminal output. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.handler.ts:123 |
terminal-output |
claude+codex | Color preferences govern terminal layout, so forced color can truncate piped output while a no-color TTY can get unbounded rows. |
| 🟡 MINOR | apps/docs/.source/server.ts:2 |
stray-artifact |
claude+codex | The PR adds four generated Fumadocs files for a docs app whose source configuration and content are absent. |
| 🟡 MINOR | apps/cli/src/commands/traces/SIDE_EFFECTS.md:20 |
documentation |
codex | The side-effects table overstates when the handler runs its cache and telemetry finalizers and when those finalizers write files. |
| 🟡 MINOR | apps/cli/src/commands/traces/traces.tree.unit.test.ts:136 |
test-quality |
codex | The error-ordering test cannot detect changes to the order of error spans. |
| ⚪ NIT | apps/cli/src/commands/traces/SIDE_EFFECTS.md:38 |
docs-accuracy |
claude | The side-effects table incorrectly says SUPABASE_API_MAX_RETRIES does not apply to the trace request. |
| ⚪ NIT | apps/cli/src/commands/traces/traces.tree.unit.test.ts:102 |
test-quality |
codex | The large-trace test claims to exercise rendering but measures only tree construction and flattening. |
| ⚪ NIT | apps/cli/src/commands/traces/traces.integration.test.ts:160 |
test-quality |
codex | The success-with-errors test duplicates the successful invocation already covered by the plain-text integration test. |
| ⚪ NIT | apps/cli/src/commands/traces/traces.integration.test.ts:225 |
test-quality |
codex | The route assertion accepts an incorrect path that contains the expected route as a substring. |
| ⚪ NIT | apps/cli/src/commands/traces/traces.render.ts:97 |
maintainability |
codex | Each renderer cell carries an unused depth field. |
| ⚪ NIT | apps/cli/src/commands/traces/traces.command.ts:21 |
docs-style |
codex | The flag description uses lowercase id in prose and uses time-relative wording for search availability. |
| ⚪ NIT | apps/cli/src/commands/traces/traces.command.ts:31 |
docs-style |
codex | The command description uses lowercase id in prose and uses may to express an uncertain outcome. |
Stats
Claude findings: 5 · Codex findings: 18 · Confirmed: 20 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
jordienr
left a comment
There was a problem hiding this comment.
Please align the generated reference and validation errors with the command’s actual behavior, and clarify how the footer selects the first error. The 110 focused tests passed. The inline comments include the cases I reproduced.
| const config = { | ||
| traceId: Flag.String("trace-id").pipe( | ||
| Flag.withDescription("The ID of the trace to look up. Trace search is unavailable."), | ||
| Flag.optional, |
There was a problem hiding this comment.
Every successful lookup requires --trace-id, but the generated reference gives it an empty default and omits the required badge. Please keep the tailored missing-ID error and add Flag.annotate(FlagDocumentation, { required: true }), following gen bearer-jwt. Describe the 32-character lowercase hexadecimal format and add a Command.withExamples invocation with both --experimental and --trace-id so users can copy it from help or the reference.
| yield* requiredExperimentalAccess.check; | ||
| return yield* tracesGet(flags).pipe( | ||
| withCommandTelemetry({ flags }), | ||
| Effect.provide(managementApiRuntimeLayer(["traces"])), |
There was a problem hiding this comment.
With a clean CLI home, supabase traces --experimental --trace-id bad --output-format json returns AccessTokenRequiredError. This layer loads credentials before the handler validates the ID, so the user is told to log in to fix a malformed argument. Please defer credential resolution until flag validation passes and cover this case through the real command entry point.
| Effect.gen(function* () { | ||
| yield* requiredExperimentalAccess.check; | ||
| return yield* tracesGet(flags).pipe( | ||
| withCommandTelemetry({ flags }), |
There was a problem hiding this comment.
-o csv tells users to choose from env, pretty, json, toml, and yaml. Following that advice with -o json then tells them -o is unsupported. Please pass outputFormats: GLOBAL_OUTPUT_FORMATS to the wrapper, following logs, so both values reach the handler and point users to --output-format json|stream-json.
|
|
||
| const closingLine = | ||
| summary.errorSpanIds.length > 0 | ||
| ? `\nTrace has errors. First error span: ${shortenTraceId(sanitizeInlineName(summary.errorSpanIds[0]!))}\n` |
There was a problem hiding this comment.
On a trace with errors in sibling branches at +2ms and +50ms, the footer reported the +50ms span as “First error span” because its branch appeared first in the tree. Please choose the earliest error by start time, or label this “First error shown” if the footer is meant to follow display order. A sibling-branch test would capture the distinction.
Coly010
left a comment
There was a problem hiding this comment.
Hey 👋 thanks for this, the span tree output is really nice to read
Requesting changes, but it's about how the command is gated, not the command itself.
Blocking:
traces uses the per-command --experimental gate (requiredExperimentalAccess). Unless im mistaken, that means it's listed in supabase --help for everyone, and with withSidebar it ends up in the generated reference docs and sidebar as well - I checked on this branch and supabase traces is in both. For something still in closed alpha I don't think we want to advertise it to users who can't use it yet.
Since warehouse (#7640), closed-alpha features use a project-level toggle instead, which keeps the command out of the tree, help, completion and the stable docs until the project opts in. Could we move traces over to that?
[experimental.traces] enabled = true/SUPABASE_EXPERIMENTAL_TRACES_ENABLED- a table withenabled, not a bareexperimental.traces = true(that's the shape #7847 just moved stack and compute to)- register it in
featureSchemas/featureKeysinshared/config/experimental-feature.tsand mount the command conditionally inroot.ts, the same way compute is - add
["experimental", "traces"]toDOCUMENT_ONLY_LOCAL_PATHSinhosted-sections.ts, otherwiseconfig diff/config pullwill treat it as a hosted setting - move the code under
src/commands/experimental/traces/, which is whereapps/cli/AGENTS.mdputs opt-in commands
Non-blocking:
Closes #in the description is empty - could you link the issue this is for?
otherwise, it looks good to me!
Summary
Adds an experimental
supabase tracescommand that looks up a trace by id and prints its spans, using the Management API'sv2-get-traceoperation via the generatedpackages/apiclient. Gated behind--experimental/SUPABASE_EXPERIMENTAL=1: closed alpha, trace search doesn't exist yet, and the output may still change.Linked issue
Closes #
open-for-contributionlabel (or I'm a Supabase maintainer).Checklist
fix(cli): …).pnpm check:allpasses for every workspace touched by this PR; relevant package tests pass for every touched workspace, andpnpm types:checkpasses for each touched TypeScript workspace.