Repository navigation
test(server): guard schema.migrate on migration/execute; typecheck the CLI in CI - #489
Merged
Merged
Conversation
…e CLI in CI
Two gaps a review of this branch turned up, both already on main:
- POST /api/migration/execute applies DDL to a real database, and its
requirePermissions('schema.migrate') guard is the only check on that
path: unlike Compare, no service re-checks the permission. Nothing
tested it, so dropping the guard left the suite green.
migration.routes.test.ts now asserts that an actor with everything
short of schema.migrate gets 403 before the connection is looked up,
and that one with schema.migrate gets past the guard. Deleting the
guard fails the first test.
- `npm run typecheck`, which CI's build gate runs, covered apps/web
(with the packages) and apps/e2e but never apps/cli, whose esbuild
build does not type-check. A planted type error in apps/cli/src passed
it. The script now also runs `tsc -p apps/cli/tsconfig.json`, which
passes today and adds about 11 s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PyNv48vpYUw2HhpjYFNUi
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: d4959be0-c803-4ccb-b723-30210f501b0e) |
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.
A code review of the previous branch turned up two gaps that were already on
main. This PR closes both.1. The
schema.migrateguard on/api/migration/executewas untestedPOST /api/migration/executeapplies DDL to a real database. ItsrequirePermissions('schema.migrate')guard (migration.routes.ts:54) is the only check on that path. Compare has a second check inCompareService, with its own test; migrate has none. Removing the guard left the suite green.The new
packages/server/src/features/migration/migration.routes.test.tsfollows the pattern ofaccess.routes.test.ts, with a Fastify instance and an authenticated user whose permissions the test chooses. It checks two things:schema.migrate: a user who can browse, compare and run SQL, but not migrate, gets 403forbidden. The connection is never looked up and nothing executes.schema.migrate: the user gets past the guard.2. CI never type-checked
apps/clinpm run typecheck, which the build gate runs, coveredapps/web(includingpackages/*) andapps/e2e.apps/clihas its own strict tsconfig, and its esbuild build does not type-check. The script now also runstsc --noEmit -p apps/cli/tsconfig.json. That passes today and adds about 11 seconds.Verification
requirePermissions('schema.migrate')guard removed, the first new test fails. With it in place, both pass.apps/cli/srcpasses the oldtypecheck(exit 0) and fails the new one (TS2322).npm run typecheck: clean.npx vitest runon Node 24: 480 test files passed, 8 skipped; 5860 tests passed.🤖 Generated with Claude Code
https://claude.ai/code/session_016PyNv48vpYUw2HhpjYFNUi
Generated by Claude Code
Note
Low Risk
Test-only and CI script changes; no production behavior or auth logic is modified.
Overview
Adds regression coverage for
POST /migration/execute: users withoutschema.migrateget 403 before connection lookup or migration execution; users with the permission pass the route guard.Extends root
npm run typecheckto includeapps/cli/tsconfig.json, so CI type-checks the CLI alongside web and e2e.Reviewed by Cursor Bugbot for commit a463b01. Bugbot is set up for automated code reviews on this repo. Configure here.