Skip to content

Commit b1054e5

Browse files
committed
chore(release): 2.3.0 -- configurable API-error exit code
Minor bump for the new --exit-code-on-api-error flag and the supporting non-breaking improvements (commit-message truncation, Buildkite-aware infra error logging, --timeout / --exclude-license-details fixes). This release is intentionally NON-breaking: default exit codes are unchanged, the exit code only shifts when --exit-code-on-api-error is explicitly passed, and --disable-blocking keeps its existing precedence. The breaking exit-code behavior change (infra errors exiting non-zero even under --disable-blocking) is deferred to a future 3.0. CHANGELOG + README document the flag AND its interaction with --disable-blocking (which overrides it) to reduce user error in the Buildkite soft_fail setup. Version refs synced across pyproject.toml, socketsecurity/__init__.py, and uv.lock (per the version-incrementation CI check). Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent 9867c98 commit b1054e5

5 files changed

Lines changed: 92 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
# Changelog
22

3+
## 2.3.0
4+
5+
### New: `--exit-code-on-api-error`
6+
7+
Adds a configurable exit code for API / infrastructure failures (timeouts,
8+
network errors, unexpected exceptions), so CI pipelines can distinguish them
9+
from blocking security findings (exit `1`):
10+
11+
```
12+
socketcli --exit-code-on-api-error 100 ...
13+
```
14+
15+
Default is `3` (the code the CLI already used for these errors), so **default
16+
behavior is unchanged** — the exit code only changes when you pass the flag.
17+
Set it to a Buildkite `soft_fail` code, or to `0` to swallow infra errors.
18+
19+
**Interaction to be aware of:** `--disable-blocking` forces exit `0` for *all*
20+
outcomes and therefore overrides `--exit-code-on-api-error`. Use the new flag
21+
*without* `--disable-blocking` if you want a custom infra-error code to take
22+
effect. See the exit-code reference in the README.
23+
24+
> A future `3.0` release is planned to make infrastructure errors exit non-zero
25+
> even under `--disable-blocking` (so outages stop being silently swallowed).
26+
> That is a breaking change and is intentionally **not** in this release.
27+
28+
### New: commit message auto-truncation
29+
30+
`--commit-message` values longer than 200 characters are now automatically
31+
truncated before being sent to the API, preventing HTTP 413 errors from
32+
oversized URL query parameters (common with AI-generated commit messages or
33+
`$BUILDKITE_MESSAGE`).
34+
35+
### Improved: Buildkite log formatting
36+
37+
When running inside a Buildkite job (`BUILDKITE=true`), infrastructure errors
38+
emit Buildkite log section markers (`^^^ +++` / `--- :warning:`) so the error
39+
section auto-expands in the BK UI, plus a `soft_fail` hint. No effect on other
40+
CI platforms.
41+
42+
### Fixed
43+
44+
- `--timeout` is now honored end-to-end: it was only applied to the local
45+
`CliClient`, but the full-scan diff comparison uses the Socket SDK instance,
46+
which was constructed without the CLI timeout and defaulted to 1200s.
47+
- `--exclude-license-details` now propagates to the full-scan diff comparison
48+
request (it was only applied to full-scan params / report URLs before).
49+
350
## 2.2.90
451

552
- Migrated license enrichment PURL lookup to the org-scoped endpoint (`POST /v0/orgs/{slug}/purl`) from the deprecated global endpoint (`POST /v0/purl`).

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,48 @@ Minimal pattern:
194194
SOCKET_SECURITY_API_TOKEN: ${{ secrets.SOCKET_SECURITY_API_TOKEN }}
195195
```
196196
197+
## Exit codes
198+
199+
| Code | Meaning |
200+
|------|---------|
201+
| `0` | Clean scan — no blocking issues (or `--disable-blocking` set) |
202+
| `1` | Blocking security finding(s) detected |
203+
| `2` | Scan interrupted (SIGINT / Ctrl+C) |
204+
| `3` | Infrastructure or API error (timeout, network failure, unexpected error) |
205+
206+
`--exit-code-on-api-error <N>` remaps the infrastructure-error code (`3`) to any
207+
value — e.g. a Buildkite `soft_fail` code, or `0` to swallow infra errors. Exit
208+
`3` is a Socket convention, not an industry standard.
209+
210+
### How these options interact
211+
212+
The two flags that affect exit codes can cancel each other out, so the order of
213+
precedence matters:
214+
215+
- **`--disable-blocking` wins over everything.** It forces exit `0` for *all*
216+
outcomes — security findings *and* infrastructure errors. If you set it,
217+
`--exit-code-on-api-error` has no effect (you'll always get `0`).
218+
- **`--exit-code-on-api-error` only applies when `--disable-blocking` is *not*
219+
set.** It changes the infra-error code (and the generic-error code); it never
220+
touches the security-finding code (`1`).
221+
222+
So for the common "don't let Socket outages block my pipeline, but still fail on
223+
real findings" goal, use `--exit-code-on-api-error` **without** `--disable-blocking`:
224+
225+
```yaml
226+
# Buildkite: soft-fail only on infrastructure errors, still block on findings
227+
steps:
228+
- label: ":lock: Socket Security Scan"
229+
command: "socketcli --exit-code-on-api-error 100 ..." # NOT --disable-blocking
230+
soft_fail:
231+
- exit_status: 100
232+
```
233+
234+
Combining `--disable-blocking` with `--exit-code-on-api-error 100` would make the
235+
scan exit `0` on *both* findings and outages — the `soft_fail: 100` rule would
236+
never match, and real findings would stop blocking. That's usually not what you
237+
want.
238+
197239
## Common gotchas
198240

199241
See [`docs/troubleshooting.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#common-gotchas).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.2.91"
9+
version = "2.3.0"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.91'
2+
__version__ = '2.3.0'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)