fix(fix): propagate Coana discovery failures + consume structured discovery result - #1444
Open
Martin Torp (mtorp) wants to merge 5 commits into
Open
fix(fix): propagate Coana discovery failures + consume structured discovery result#1444Martin Torp (mtorp) wants to merge 5 commits into
Martin Torp (mtorp) wants to merge 5 commits into
Conversation
Martin Torp (mtorp)
force-pushed
the
fix/fix-discovery-silent-noop
branch
from
July 29, 2026 09:00
812e9da to
e07ef51
Compare
Benjamin Barslev Nielsen (barslev)
approved these changes
Jul 29, 2026
…cess socket fix silently exited 0 with "Finished!" whenever the GHSA discovery step failed, because discoverGhsaIds collapsed every failure mode — Coana exiting non-zero, the dlx launcher failing to fetch @coana-tech/cli, empty stdout, or an unparseable final line — to an empty GHSA list, indistinguishable from "nothing to fix". discoverGhsaIds now returns CResult<string[]>: a failed Coana spawn propagates its error (exit code and stderr intact), and empty, non-JSON, or wrongly-shaped output fails with a specific message. A genuine empty array still exits 0. Both call sites (local and CI/PR mode) propagate the failure so outputFixResult sets a non-zero exit code and the real reason reaches the user.
Coana 15.9.7 adds `find-vulnerabilities --output-file`, writing a
structured JSON result ({ ghsaIds, artifactCount, filteredArtifactCount })
that replaces the brittle "JSON array on the final stdout line" contract
(coana-tech/coana-package-manager#2327).
discoverGhsaIds now prefers that file when the resolved Coana version
supports it (or when using a local Coana build), falling back to strict
stdout parsing for older versions. A missing, unparseable, or wrongly
shaped result file fails the run with a specific message instead of
silently skipping fixes.
The artifact counts also close the remaining diagnostic hole: when the
backend resolved 0 artifacts, an empty result is almost certainly a
server-side resolve problem rather than "nothing to fix", so the CLI
now warns instead of only printing "Finished!".
The pinned @coana-tech/cli is now 15.9.7, which always supports `find-vulnerabilities --output-file`, so the Coana version is known at build time and no backward compatibility is needed: drop the version gate and the stdout final-line parsing fallback. Discovery now always passes --output-file and reads the structured result; a missing, unparseable, or wrongly shaped result file fails the run with a specific message.
Martin Torp (mtorp)
force-pushed
the
fix/fix-discovery-silent-noop
branch
from
July 29, 2026 12:20
a52d44a to
645d428
Compare
Martin Torp (mtorp)
marked this pull request as ready for review
July 29, 2026 12:51
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 645d428. Configure here.
Guard readStructuredDiscoveryResult against non-object JSON bodies (null, arrays, scalars): destructuring null threw a TypeError instead of the intended ok:false result. Also delete the --output-file temp path when the Coana spawn fails — cleanup previously only ran on the success path.
A silent no-op exits 0, so the `if (code !== 0)` guard hid all CLI output for exactly the failure class that is hardest to diagnose (e.g. discovery returning an empty id list). The catch block now logs unconditionally, so the next occurrence shows what Coana and the backend actually reported — including the zero-artifact warning.
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.

Problem
socket fixsilently reported success when its GHSA discovery step failed.discoverGhsaIdscollapsed every failure mode to an empty list:npx/pnpm dlxfailing to fetch@coana-tech/clicatch {})An empty id list then short-circuited
coanaFixwithok: true, whichoutputFixResultrenders as "Finished!" with exit code 0. A broken Coana in a customer's CI was indistinguishable from "nothing to fix" — and because the fix E2E tests only dump CLI output on non-zero exit, a silent no-op produced zero diagnostics (the flaky Python E2E test that exits 0 yet upgrades nothing).A second, subtler hole: "backend resolved zero artifacts" and "genuinely nothing to fix" both surfaced as an empty list, with no way to tell them apart.
Changes (5 commits)
1.
fix(fix): propagate Coana discovery failures instead of reporting successdiscoverGhsaIdsreturnsCResult<string[]>: a failed Coana spawn propagates itsCResultas-is (exit code and stderr intact viabuildDlxErrorResult); empty stdout, a non-JSON final line, or wrongly-shaped JSON each fail with a specific message. A genuine empty result still exits 0. Both call sites (local and CI/PR mode) propagate the failure, so the real reason reaches the user with a non-zero exit — and the E2E exit-code assertion failure now dumps CLI output, making the next occurrence self-diagnosing.2.
feat(fix): consume Coana's structured discovery result + 3. bump@coana-tech/clito 15.9.7coana-tech/coana-package-manager#2327 (released as coana 15.9.7) adds
find-vulnerabilities --output-file <file>, writing a structured result:{ "ghsaIds": ["GHSA-..."], "artifactCount": 137, "filteredArtifactCount": 42 }Since the Coana version is pinned in this repo, discovery now always uses
--output-fileand reads that file — the brittle "JSON array on the final stdout line" parsing is gone entirely. A missing, unparseable, or wrongly-shaped result file fails the run with a specific message.The artifact counts also close the second hole: when the backend resolved 0 artifacts, an empty result is almost certainly a server-side resolve problem rather than "nothing to fix", so the CLI now warns (
The Socket backend resolved 0 artifacts…) instead of only printing "Finished!".4.
fix(fix): plug discovery result edge cases (Cursor Bugbot)readStructuredDiscoveryResultno longer throws aTypeErroron non-object JSON bodies (null, arrays, scalars) — they return the intendedok: false. The--output-filetemp path is now also removed when the spawn fails (previously only cleaned up on success).5.
test(fix): log CLI output on any e2e failure, not just non-zero exitsA silent no-op exits 0, so the
if (code !== 0)guard hid all CLI output for exactly the failure class that is hardest to diagnose. The E2E catch blocks now log unconditionally, so the next flake occurrence shows what Coana and the backend actually reported — including the zero-artifact warning.Compatibility
--coana-versionto something older than 15.9.7 will get a loudunknown option '--output-file'failure (propagated by commit 1) instead of a silent no-op — acceptable since the version is pinned.spawnCoanaDlxmaps that took: false, which now propagates.Tests
handle-fix-limit.test.mts: 24 tests, all passing;tsgo/oxlint/eslintclean. Discovery mocks now write the structured envelope the way coana 15.9.7 does.@coana-tech/cli@15.9.7exposes-o, --output-file(find-vulnerabilities --help).Behavior change (intended)
Automation parsing
socket fix --jsonthat relied onok: true+ emptyghsaDetailswhen Coana was broken now getsok: false+ message and a non-zero exit.Note
Medium Risk
Changes
socket fixsuccess/failure semantics and JSONokfor discovery errors, which can break automation that treated failed Coana runs as success; core fix path behavior is otherwise localized to discovery.Overview
socket fixno longer treats a broken vulnerability-discovery step as “nothing to fix.” Discovery failures (Coana non-zero exit, missing/unreadable--output-fileJSON) now returnok: falsewith a non-zero exit instead ofFinished!with an empty result.Discovery always runs Coana
find-vulnerabilitieswith--output-file(Coana 15.9.7) and readsghsaIdsplusartifactCountfrom that JSON, replacing parsing the last stdout line. WhenartifactCountis 0, the CLI warns that backend resolve may be incomplete rather than only showing an empty list.@coana-tech/cliis bumped to 15.9.7 (version 1.1.150). Tests mock the structured envelope and cover failure propagation and invalid discovery output.Reviewed by Cursor Bugbot for commit 645d428. Configure here.