Repository navigation
Backend review: security, correctness and performance fixes - #443
Merged
Merged
Conversation
Security
- Refuse to start with the default JWT_SECRET under NODE_ENV=production.
- JWT carries `sub`; email-only tokens accepted while JWT_LEGACY_EMAIL_TOKENS
is not false.
- Global ValidationPipe with whitelist: unknown body fields are dropped.
- PATCH /test-runs/update/:id changes only `comment`.
- /users/all and PATCH /users/assignRole no longer return apiKey.
- Image names validated (closes an open redirect); downloads are streamed.
- Seed no longer logs users, never promotes an existing user, generates a
first admin's password and key when env does not set them.
- Container runs as uid 1000 when the image volume allows it
(VRT_RUN_AS_ROOT to keep root); HTTPS_KEY_PATH / HTTPS_CERT_PATH are read.
- REGISTRATION_ENABLED, STRICT_BUILD_PROJECT_CHECK; LDAP rejects empty
passwords and times out.
API (backward compatible)
- Error body is {statusCode, path, name, message}; client errors that gave
500 now give 400/404/409/413/422; a full diff queue gives 503 with
Retry-After; /health gives 503 without a database.
- New: POST /test-runs/revert, GET /users/registration/enabled.
- Websocket testRun_* events carry TestRunDto; empty events are not sent.
Behaviour and performance
- Ignore areas are rounded and clipped to the image.
- Auto-approve compares each baseline once and skips size mismatches by the
PNG header; VLM projects use the pixelmatch verdict there.
- Build retention skips builds with recent uploads
(BUILD_RETENTION_GRACE_MINUTES) and runs in the background.
- Repeated approve no longer duplicates the baseline; deletes remove rows
before files and surface errors.
- Image work stays in the diff worker pool with job timeouts and heap limits;
timeouts for S3, LDAP, Redis, Ollama and Gemini.
Database
- Three indexes via CREATE INDEX CONCURRENTLY and TestRun.statusBeforeDecision.
Tests and build
- Coverage thresholds raised and met; e2e and auth setup deduplicated.
- Docker image gated on typecheck; compose binds Postgres to 127.0.0.1,
api waits for the migration and has a healthcheck.
Clients skip testRun_created for runs they already fetched over HTTP, so an approve within the debounce window left the UI on the old status. The queued created entry is still refreshed, and the run now goes to the updated queue too, so both events carry the latest state.
|
Important Review skippedToo many files! This PR contains 240 files, which is 140 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
Deployments that never changed the sample secret kept starting before this branch; an upgrade must not stop them.
…akes before a diff job
Timeouts (Ollama, Gemini, S3, LDAP, Redis, diff job), VLM concurrency and the build retention grace become constants. Foreign build ids are always accepted with a warning, email-only tokens are always accepted, and the entrypoint drops root whenever the volume allows it. None of these variables reached master.
3 of 4 tasks
…nd runs api and migration on pull requests
This was referenced Nov 1, 2026
Merged
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 full review of the backend with its fixes: security, correctness, performance, indexes, a leaner test suite and a stricter build. Backward compatible with existing SDKs, the frontend and deployments: an upgrade needs no manual step.
Worth knowing when upgrading
JWT_SECRET: a publicly known value (jwtPrivateKey, the one in.env) only logs a warning; set a random one (openssl rand -hex 32).CREATE INDEX CONCURRENTLY, one addsTestRun.statusBeforeDecision. Themigrationservice applies them. Writes are not blocked, but avoid deploying around 00:00, when the nightly cleanup runs./imageUploadsvolume and the TLS files are accessible to it. Otherwise it stays root and logs a warning. To switch, runchown -R 1000:1000 <images volume>(and the TLS files).HTTPS_KEY_PATH/HTTPS_CERT_PATHare now read: if a deployment set them and the files exist, the server starts serving HTTPS.sub(the user id). Older email-only tokens are still accepted.127.0.0.1only; a tool that reached it from another host needs its own port mapping.apistarts after the migration succeeds and has a healthcheck.API changes (backward compatible)
Error body is
{statusCode, path, name, message}, withoutexceptionorstack.Client errors that returned 500 now return 4xx:
MAX_IMAGE_PIXELS: 422;take/skip: 400.A full diff queue answers 503 with
Retry-After./healthanswers 503 without a database.New endpoints:
POST /test-runs/revert(undo an approve or reject) andGET /users/registration/enabled.apiKeyremoved from/users/allandPATCH /users/assignRoleresponses.PATCH /test-runs/update/:idchanges onlycomment.Global
ValidationPipewithwhitelist: unknown body fields are dropped silently, not rejected.Websocket
testRun_*events:TestRunDto(nochangeSignature,pixelMisMatchCount,createdAt,updatedAt,projectId);build_createdgoes out once;testRun_updated, and also refreshes a still-queuedtestRun_created.Image names are validated (closes an open redirect). Downloads are streamed with
Cache-Control: immutable.LDAP:
changePasswordgives 400;PUT /usersignores the email in the body.Behaviour
buildIdon upload is accepted with a warning.New environment variables
All optional, with defaults:
REGISTRATION_ENABLED(true),MAX_IMAGE_PIXELS(100 MP,0= no limit),DIFF_WORKER_MAX_HEAP_MB(512),MULTIPART_FILE_SIZE_LIMIT(100 MiB),LOG_LEVEL. Timeouts for Ollama and Gemini (5 min), S3 (5 s connect, 60 s request), LDAP (5 s connect, 10 s operation), Redis (30 s) and a diff job (120 s) are fixed in code, as are VLM concurrency (4) and the retention grace (60 min). Details are in the README, under "Environment variables".Development
@swc/jest, andts-jestis removed;noUnusedLocals,noImplicitReturns,noImplicitOverrideandnoFallthroughCasesInSwitch.lodash,body-parser,passport-local,tsconfig-paths,eslint-config-prettierand the rootjest-mock-extended;expressandsocket.ioare declared explicitly.NODE_TLS_REJECT_UNAUTHORIZED=0removed from both Dockerfiles.How it was verified
On the head commit:
npm run typecheck,npm run lint,npm run format:check: clean.npm run test:cov: 1629 tests, coverage 99.94 / 99.15 / 100 / 99.94.npm run build: passes.npx prisma migrate deployapplies every migration;prisma migrate diff --from-config-datasource --to-schema prisma/schema.prisma --exit-codereports no difference;npm run test:e2e: 302 tests.b47b130)./health,test:acceptance,test:ldap,test:oidc) runs in this PR's CI; theprisma/package tests (23) passed earlier in the review.Left as is
dinov2Checkon but the server has noDINOV2_URL. The run then goes to review with a warning in the log, so nothing is approved by mistake; only the gate computation is wasted.src/compare/test-utils.tsholds PNG helpers shared by the compare specs, so it is excluded from the build and from coverage.Follow-ups
POST /test-variations/merge;WS_AUTH_REQUIRED, plusjoin/leaverooms;openapi.jsonwith a drift check in CI.multer2.5.0 override, once the release is two weeks old.🤖 Generated with Claude Code