Repository navigation
Add socket-patch report to tell Socket that a patch broke something - #2193
Conversation
There was no way to say that a patch broke a project: rollbacks were counted, but nothing said why, and a patch that broke a build without being rolled back was never heard of. `socket-patch report <patch>... [--reason build|tests|runtime|other] [--message <text>]` sends one `patch_reported` event on the route the run's telemetry takes. It names each patch by UUID with its ecosystem and patch mode, the reason, and the message the user typed (on one line, URL credentials and the home directory redacted, cut to 1000 characters). No package name, path or file content is sent. A PURL or a package name selects the patches the project holds for that package; a UUID names any patch, so one that was already rolled back can still be reported. A name the project holds no patch for, or one that reaches several packages, is an error and sends nothing. A report is something the user asked to send, so the telemetry opt-outs do not stop it; `--offline` does. Unlike a telemetry event the run waits for the answer, and a report the endpoint did not take is a failed run (`report_not_sent`, exit 1). `--dry-run` shows what would be sent. The project is never changed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A patch is usually rolled back because it broke something, and once it is off the project no longer holds it: only its UUID still names it. A `rollback` that named its targets, took off one to three patches and runs at a terminal with a person at it now ends with one line giving the command that reports them: Did this patch break something? Tell Socket: socket-patch report <uuid> --message "what happened" Never on a dry run, under `--json` or `--silent`, in a pipe, in an AI coding agent's terminal, or after a bare `rollback`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Findings from the review of the `report` command, fixed: - A report of more than 50 patches said all were reported while the event carried 50. One report now names at most 50 and never leaves one out: more is `too_many_patches`, and a long message beside a full list is cut further instead of the list. - A patch that is both in the manifest and vendored was reported as an agent patch, a manifest record the vendored artifact had replaced was reported in its place, and a vendor ledger entry with no embedded record could not be named at all. The report now reads the vendor ledger's own entries and names the patch the build consumes: the vendored artifact, else the hosted pin, else the manifest's record. - The hint after a rollback printed the recorded patch id inside a command to run. A manifest's `uuid` is a string a project file supplies, so only an id that is a UUID is printed; a run that took off a patch with any other id prints no hint. - A saved login the org endpoint refuses (401 / 403) failed the report. It is sent again without the token, on the public route. - A report that got no answer now says why (the cause chain of the request error), not only that the request failed. - A manifest or vendor ledger that cannot be read is named as the problem when a PURL or a name then matches nothing, instead of `patch_not_found`. A report by UUID still goes out. - A human run prints the whole report: each patch with its mode, and the message as it was sent, so `--dry-run` shows the redaction. - Comments no longer describe a `rollback --report` flag. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PR SummaryMedium Risk Overview Reporting bypasses telemetry opt-outs (only Docs and CLI contract are updated; parse, e2e, telemetry unit, and rollback render tests cover the new surface. Reviewed by Cursor Bugbot for commit e1c2bf2. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e1c2bf2. Configure here.
A name or purl was resolved against the stores that could still be read, so with an unreadable vendor ledger a report went out under the manifest's or a hosted pin's UUID and mode, not the vendored copy the build consumes. Refuse any non-UUID target with the store's error and the UUID hint instead; a UUID report still goes out. Assisted-by: Claude Code:claude-opus-5-5

Builds on #2178 (merged): it uses that PR's per-patch telemetry entries.
What this adds
There was no way to tell Socket that a patch broke a project. Rollbacks are counted, but nothing says why, and a patch that broke a build without being rolled back was never heard of.
rollback <target>uses). Where it holds patches for one package in several modes, the report names the one the build consumes: the vendored artifact, else the hosted pin, else the agent manifest's record. A UUID names any patch, so one that was already rolled back can still be reported. A name the project holds no patch for (patch_not_found), one that reaches several packages (ambiguous_target), or more than 50 patches (too_many_patches) is an error and sends nothing.patch_reportedevent on the route the run's telemetry takes: each patch's UUID, ecosystem and patch mode, the reason (build,tests,runtimeorother, the default), the message, and the CLI's version and platform. No package name, path or file content. The message goes out on one line, with URL credentials and the home directory redacted, cut to 1000 characters.report_not_sent, exit 1, with the cause). A saved login the org endpoint refuses (401 / 403) does not cost the report: it is sent again without the token on the public route.--dry-runshows the whole report as it would be sent, message redaction included, and sends nothing. The project is never changed.rollbackthat named its targets, took off one to three patches and runs at a terminal with a person at it ends with one line giving the command to report them:Did this patch break something? Tell Socket: socket-patch report <uuid> --message "what happened". Never on a dry run, under--jsonor--silent, in a pipe, in an AI coding agent's terminal, or after a barerollback.This is deliberately the small version: one command and one event on the existing route. No new endpoint, no wizard, no local record of reports, no
rollback --reportflag.Decisions a reviewer should check
--no-telemetry,SOCKET_TELEMETRY_DISABLEDandDO_NOT_TRACKdo not stop a report, because the user ran the command to send it.--offline/SOCKET_OFFLINEdoes (offline_unsupported). If a report should honour the opt-outs instead, it is one condition insend_patch_report.--jsonconsumer sees it.-mshort for--message.-mis reserved (it was--manifest-path), and a test pins that.patch_reported. Until it does, a report is stored but not categorised with the other patch events. The backend change is in review separately; this should not be released before it.Testing
crates/socket-patch-coretelemetry::unit tests: the event's body, the opt-outs, offline, an endpoint that refuses, one that is unreachable, the message's redaction and cap.tests/report_e2e.rs: the built binary against a mock endpoint: a UUID from an empty directory, a package name resolved against a manifest,--dry-run,--silent,--json, a name that matches nothing, a refusing endpoint,--offline, a refused login, an unreadable manifest, and the 50-patch cap.tests/cli_parse_report.rs: the argument surface.tests/rollback/rollback_render.rs: the hint on a pseudo-terminal, and its absence on a dry run, in a pipe and after a bare rollback.rollbacksuite (141),cli_global_args,cli_parse_main,help_text_hygiene,command_module_layering,json_error_shape, all passing. The full suite and the other platforms are left to CI.Review
/code-review highran on this diff and returned ten findings. Eight are fixed in the last commit (its message lists them). Two are not code changes:mode: "unknown"and no ecosystem. By then the project no longer holds the patch, and passing both through the hinted command would need two more flags. The patch's UUID is the signal; the contract now says so.patch_reportedbefore a release. That cannot be checked from this repo. It is decision 4 above.🤖 Generated with Claude Code
Generated by Claude Code