Skip to content

[NO-TICKET] Add PATCHSTACK_SOFT_FAIL so connector errors never break builds#34

Open
ejntaylor wants to merge 1 commit into
mainfrom
elliot/soft-fail-env
Open

[NO-TICKET] Add PATCHSTACK_SOFT_FAIL so connector errors never break builds#34
ejntaylor wants to merge 1 commit into
mainfrom
elliot/soft-fail-env

Conversation

@ejntaylor

Copy link
Copy Markdown
Contributor

Why

A Lovable publish (project e5840a4d-…) failed with script "postbuild" exited with code 1 even though the app build succeeded. The postbuild script invoked patchstack-connect with a subcommand the CLI doesn't recognize, so the CLI printed its usage to stderr and exited 1 — and the platform failed the whole deploy.

AI coding tools (Lovable, Bolt, Cursor, …) are the ones wiring this connector into build scripts, and they sometimes get the invocation wrong. A security monitor should degrade gracefully in that position: report the problem, never take the customer's deploy down with it.

What

  • New PATCHSTACK_SOFT_FAIL environment variable: when set (any value except 0/false/no/off), the CLI prints the error exactly as before, then exits 0. Covers both the unknown-command path and runtime failures (PatchstackError, unexpected errors).
  • Manual/interactive use is unchanged unless the variable is set — you still see real exit codes by default.
  • README: the AI install prompt and build-wiring example now use PATCHSTACK_SOFT_FAIL=1 patchstack-connect scan, plus a note explaining the trade-off; env var documented in Configuration. The install prompt also now tells the AI tool not to invent subcommands.
  • softFailEnabled() lives in src/config.ts with unit tests.

Verification

  • npx vitest run — 116 tests pass; tsc --noEmit clean.
  • Built CLI exercised end-to-end:
    • node dist/cli.js bogus → exit 1 (unchanged)
    • PATCHSTACK_SOFT_FAIL=1 node dist/cli.js bogus → prints usage + notice, exit 0
    • PATCHSTACK_SOFT_FAIL=false … bogus → exit 1 (opt-out honored)
    • PATCHSTACK_SOFT_FAIL=1 … status --site-uuid not-a-uuid → prints Error (CONFIG_INVALID): …, exit 0
    • success paths exit 0 with no extra output

🤖 Generated with Claude Code

A Lovable publish failed because the project's postbuild script invoked
the CLI with an unrecognized subcommand: the CLI printed usage to stderr
and exited 1, which failed the entire deploy even though the app build
itself succeeded. AI coding tools wire the connector into build scripts,
and they sometimes get the invocation wrong — a security monitor should
degrade gracefully there, not take the site down with it.

PATCHSTACK_SOFT_FAIL (any value except 0/false/no/off) makes the CLI
print the error as before but exit 0, covering both bad usage and
runtime failures (network, config). Manual runs are unaffected unless
the variable is set. The README install prompt now recommends it for
build wiring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderbuds

coderbuds Bot commented Jul 13, 2026

Copy link
Copy Markdown

Adds soft-fail flag so connector errors never break builds.

🎯 Quality: 100% Elite · 📦 Size: Small

📈 This month: Your 218th PR — above team average · Averaging Excellent

See how your team is trending →

@ejntaylor

Copy link
Copy Markdown
Contributor Author

/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants