fix(upload): make outdated-CLI bundle upload failure actionable - #3333
posthog-eu[bot] wants to merge 2 commits into
Conversation
Old @capgo/cli (< MIN_CLI_VERSION) finalizes uploads by writing app_versions.manifest jsonb, which the check_encrypted_bundle_on_insert trigger blocks. The user saw only a raw Postgres P0001 that named an internal endpoint and gave no way to recover. - Rewrite the trigger's r2_direct_manifest_jsonb message to tell the user to update the CLI. The old CLI finalizes via direct PostgREST, so the trigger is the only chokepoint every upload path passes through; guard behavior and the pg_log reason are unchanged. - Enforce MIN_CLI_VERSION server-side on the presigned upload-link request so the doomed upload is rejected before any files transfer. TUS uploads still fail at the trigger, which now carries the same upgrade message. Generated-By: PostHog Desktop Task-Id: eb8ace10-e0bd-405f-b31f-a7e3efee2497
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
…t_manifest_jsonb-9ac755
|



Summary
Outdated
@capgo/cli(older thanMIN_CLI_VERSION) cannot finish a bundle upload, and the user sees only a raw PostgresP0001error that names an internal endpoint — with no hint to upgrade.app_versions.manifestjsonb directly via PostgREST. Thecheck_encrypted_bundle_on_inserttrigger (correctly) blocks that write and raisesr2_direct_manifest_jsonb: Use POST /private/set_manifest .... The guard is right; the response is the bug — that text is meaningless to a CLI user.MIN_CLI_VERSIONis published only viaGET /private/configand enforced inside the CLI, so a CLI too old to read it never checks it.Changes
r2_direct_manifest_jsonbmessage to tell the user to runnpx @capgo/cli@latest. The direct-PostgREST finalize passes through no edge function, so the DB trigger is the one chokepoint every upload path reaches — guard logic and thepg_logreason are unchanged.assertUploadCliVersionSupportedhelper readsx-cli-versionand rejects a below-floor CLI on the presigned upload-link request, before any files transfer. Requests without a parseable version header are left alone (non-CLI and self-hosted clients).Test plan
supabase/tests/73_test_block_r2_direct_manifest_jsonb.sql— pgTAP assertions updated to the new message (INSERT, UPDATE, finalize).tests/manifest-poison-guard.test.ts— direct PostgREST poison PATCH now asserts the upgrade hint in the response.tests/private-error-cases.test.ts— new cases: below-floorx-cli-versionis rejected withcli_version_too_old; an unparseable header falls through the gate.oxlintpasses on the changed backend files. The fullbun run lint:backend && bun run lintand the integration suites need the project toolchain (bun/deno/supabase), which was not available in this environment, so they were not run here.Screenshots
N/A — backend and DB-trigger change only.
Checklist
bun run lint:backend && bun run lint.accordingly.
my tests
Created with PostHog Desktop from this inbox report.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.