Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(release): wait for npm registry visibility (#1239)

mldangelo-oaif3fd5280d53e
diff --git a/.github/workflows/node-github-release.yml b/.github/workflows/node-github-release.yml
index de67b55c2..ef50c193d 100644
--- a/.github/workflows/node-github-release.yml
+++ b/.github/workflows/node-github-release.yml
@@ -189,6 +189,37 @@ jobs:
printf 'run-id=%s\n' "$release_run"
} >> "$GITHUB_OUTPUT"
+ - name: Wait for the published npm package
+ shell: bash
+ env:
+ RELEASE_VERSION: ${{ steps.release.outputs.version }}
+ run: |
+ set -euo pipefail
+
+ # npm can finish publishing before its registry makes the version available.
+ for attempt in {1..21}; do
+ if metadata="$(
+ npm view "@openai/codex-security@$RELEASE_VERSION" version \
+ --json --prefer-online --registry=https://registry.npmjs.org/
+ )"; then
+ exit 0
+ fi
+ printf '%s\n' "$metadata" >&2
+ if ! printf '%s\n' "$metadata" | node --input-type=module --eval '
+ import { readFileSync } from "node:fs";
+ const result = JSON.parse(readFileSync(0, "utf8"));
+ process.exit(result?.error?.code === "E404" ? 0 : 1);
+ '; then
+ exit 1
+ fi
+ if (( attempt == 21 )); then
+ echo "The published npm version did not become available within ten minutes." >&2
+ exit 1
+ fi
+ echo "Waiting for npm publication to become available." >&2
+ sleep 30
+ done
+
- name: Download the verified or durable npm release artifact
shell: bash
env:
diff --git a/RELEASING.md b/RELEASING.md
index f860d8cde..a77f67b1e 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -231,6 +231,11 @@ for that exact commit:
archive before publishing the GitHub release. It prepends the reviewed
summary to GitHub's categorized notes.
+After npm accepts a publication, its registry can take several minutes to expose
+the version. GitHub publication waits up to ten minutes for that version to
+become available before verifying its archive and signed provenance. Other
+registry errors fail immediately.
+
`node-release` generates the npm plugin payload from the canonical source under
`plugins/codex-security/` during `prepack`. The generated
`sdk/typescript/_bundled_plugin/` directory is not a committed release input;
diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts
index d06a8a9dc..d7dd4ca01 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -2625,6 +2625,91 @@ describe("GitHub release workflow safeguards", () => {
expect(githubReleaseWorkflow).not.toContain("TRIGGER_RUN_ID");
});
+ test.each([
+ {
+ description: "a version already visible in the registry",
+ missingAttempts: 0,
+ errorCode: "E404",
+ calls: 1,
+ waits: 0,
+ status: 0,
+ },
+ {
+ description: "a version becoming visible after npm processing",
+ missingAttempts: 4,
+ errorCode: "E404",
+ calls: 5,
+ waits: 4,
+ status: 0,
+ },
+ {
+ description: "a version remaining absent past the publication wait",
+ missingAttempts: 100,
+ errorCode: "E404",
+ calls: 21,
+ waits: 20,
+ status: 1,
+ },
+ {
+ description: "an unrelated registry authorization failure",
+ missingAttempts: 1,
+ errorCode: "E401",
+ calls: 1,
+ waits: 0,
+ status: 1,
+ },
+ ])(
+ "handles $description before GitHub release verification",
+ async ({ missingAttempts, errorCode, calls, waits, status }) => {
+ const script = workflowStepShell(
+ githubReleaseWorkflow,
+ "Wait for the published npm package",
+ );
+ const workspace = mkdtempSync(
+ join(tmpdir(), "codex-security-release-visibility-"),
+ );
+ const callLog = join(workspace, "calls.log");
+ writeFileSync(callLog, "");
+ try {
+ const mocks = [
+ "npm() {",
+ ' if [[ "$1" != "view" || "$2" != "@openai/[email protected]" ]]; then return 64; fi',
+ ' printf "query\\n" >> "$MOCK_CALL_LOG"',
+ " if (( attempt <= MOCK_MISSING_ATTEMPTS )); then",
+ ' printf \'{"error":{"code":"%s","summary":"synthetic registry diagnostic"}}\\n\' "$MOCK_ERROR_CODE"',
+ " return 1",
+ " fi",
+ " printf '\"0.1.2\"\\n'",
+ "}",
+ "sleep() {",
+ ' if [[ "$1" != "30" ]]; then return 65; fi',
+ ' printf "wait\\n" >> "$MOCK_CALL_LOG"',
+ "}",
+ ].join("\n");
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
+ env: {
+ ...process.env,
+ MOCK_CALL_LOG: callLog,
+ MOCK_MISSING_ATTEMPTS: String(missingAttempts),
+ MOCK_ERROR_CODE: errorCode,
+ RELEASE_VERSION: "0.1.2",
+ },
+ timeout: releaseWorkflowTimeout,
+ });
+ const events = readFileSync(callLog, "utf8").split("\n");
+ expect(result.status).toBe(status);
+ expect(events.filter((event) => event === "query")).toHaveLength(calls);
+ expect(events.filter((event) => event === "wait")).toHaveLength(waits);
+ if (missingAttempts > 0) {
+ expect(result.stderr).toContain("synthetic registry diagnostic");
+ expect(result.stderr).toContain(errorCode);
+ }
+ } finally {
+ rmSync(workspace, { recursive: true, force: true });
+ }
+ },
+ );
+
test("dispatches the exact protected run and release tag from trusted main", async () => {
const script = workflowStepShell(
protectedReleaseWorkflow,