Repository navigation
fix: keep nested application relations under the postgres argument limit - #7
Merged
Merged
Conversation
agentHits
force-pushed
the
fix/nested-application-column-limit
branch
from
October 6, 2026 18:12
d93c29c to
e13b437
Compare
agentHits
force-pushed
the
AgentHits-Dev
branch
from
October 6, 2026 18:12
befcbd7 to
58219e3
Compare
Что: - findDeploymentById берёт из трёх вложенных связей application (у самого деплоя, у schedule и у volumeBackup) только serverId: другие поля этих связей вызывающий код не читает. - Проверка восстановления volume backup (assertVolumeRestoreObjectBound) берёт из связей application и compose только appName. - Поиск preview-деплоя в monitoring-access берёт из связи application только applicationId и serverId. - Новый тестовый хелпер __test__/helpers/postgres-function-args.ts собирает настоящий SQL через drizzle.mock с реальной схемой и считает аргументы json_build_array. Для каждого из трёх запросов добавлен тест, который проверяет, что аргументов не больше 100. Зачем: - В таблице application 101 колонка. Drizzle кладёт все выбранные колонки вложенной связи в один вызов json_build_array, а Postgres принимает не больше 100 аргументов и отвечает ошибкой 54023 "cannot pass more than 100 arguments to a function". - Из-за findDeploymentById не работали WebSocket логов деплоя (закрывался молча), deployment.readLogs, killProcess и removeDeployment, откат через rollback и создание rollback при деплое с rollback registry. Удаление старых rollback молча пропускалось. - Из-за проверки восстановления не запускалось восстановление volume backup. - Поиск preview-деплоя выполняется для каждого имени, которое не нашлось среди application. Поэтому мониторинг compose, баз данных и preview-деплоев (WebSocket docker stats, user.getContainerMetrics) отвечал ошибкой. - Upstream уже сужал связи в findDeploymentById (97885ee), но при слиянии upstream 5a1d8ea (2026-10-01) конфликт разрешился в пользу application: true. Риски: - Если код начнёт читать из этих связей другие поля, их там не будет. Typecheck это ловит: при выборе appName вместо serverId tsc падает в listen-deployment.ts. - backup.listBackupFiles в AgentHits-Dev падает с той же ошибкой. Его чинит открытый PR #6, здесь он не менялся. В тесте PR #6 своя копия подсчёта аргументов, после слияния её можно заменить общим хелпером. Проверки: - Команды и результаты: CI=true bunx vitest run --config __test__/vitest.config.ts __test__/deployment/find-deployment-by-id.test.ts __test__/volume-backups/restore-security.test.ts __test__/server/container-resource-stats-access.test.ts - 28 тестов прошли; на старом коде три новых теста падают с "expected 101 to be less than or equal to 100" (для monitoring - 102). Полный прогон CI=true bunx vitest run --config __test__/vitest.config.ts: 2055 тестов прошли, 1 пропущен, 8 упали только в __test__/deploy/application.real.test.ts и __test__/setup/monitoring-setup.real.test.ts из-за отсутствия сокета Docker Desktop (connect ECONNREFUSED /Users/agent/.docker/run/docker.sock). bun run typecheck - 4/4 пакета без ошибок. bun run format-and-lint - 0 ошибок (33 предупреждения в других файлах, в изменённых файлах их нет). Временный vitest-аудит через toSQL (удалён перед коммитом) проверил остальные вложенные связи с application из grep: у них не больше 50 аргументов. - Ограничения: запросы не выполнялись против живой базы; *.real.test.ts без локального Docker не проверены; ничего не пушилось и не выкатывалось. What: - findDeploymentById loads only serverId from its three nested application relations (on the deployment itself, on schedule and on volumeBackup); callers read no other field from them. - The volume backup restore check (assertVolumeRestoreObjectBound) loads only appName from the application and compose relations. - The preview deployment lookup in monitoring-access loads only applicationId and serverId from the application relation. - A new test helper, __test__/helpers/postgres-function-args.ts, compiles the real SQL with drizzle.mock and the real schema and counts json_build_array arguments. Each of the three queries gets a test that checks there are no more than 100. Why: - The application table has 101 columns. Drizzle puts every selected column of a nested relation into one json_build_array call, and Postgres accepts at most 100 arguments and fails with 54023 "cannot pass more than 100 arguments to a function". - Because of findDeploymentById, the deployment log WebSocket (closed silently), deployment.readLogs, killProcess and removeDeployment, rolling back, and rollback creation during deploys with a rollback registry all failed. Removing old rollbacks was silently skipped. - Because of the restore check, a volume backup restore could not start. - The preview deployment lookup runs for every name that is not found among applications. Monitoring for compose services, databases and preview deployments (the docker stats WebSocket, user.getContainerMetrics) therefore failed. - Upstream had already narrowed the relations in findDeploymentById (97885ee), but the upstream merge 5a1d8ea (2026-10-01) resolved the conflict in favour of application: true. Risks: - Code that starts reading other fields from these relations will not find them there. Typecheck catches this: selecting appName instead of serverId makes tsc fail in listen-deployment.ts. - backup.listBackupFiles fails with the same error in AgentHits-Dev. Open PR #6 fixes it, so it is unchanged here. The PR #6 test has its own copy of the argument counter, which can switch to the shared helper after both are merged. Checks: - Commands and results: CI=true bunx vitest run --config __test__/vitest.config.ts __test__/deployment/find-deployment-by-id.test.ts __test__/volume-backups/restore-security.test.ts __test__/server/container-resource-stats-access.test.ts - 28 tests passed; on the old code the three new tests fail with "expected 101 to be less than or equal to 100" (102 for monitoring). Full run CI=true bunx vitest run --config __test__/vitest.config.ts: 2055 passed, 1 skipped, 8 failed, all in __test__/deploy/application.real.test.ts and __test__/setup/monitoring-setup.real.test.ts because the Docker Desktop socket is missing (connect ECONNREFUSED /Users/agent/.docker/run/docker.sock). bun run typecheck - 4/4 packages clean. bun run format-and-lint - 0 errors (33 warnings in other files, none in the changed files). A temporary vitest audit with toSQL (removed before the commit) checked the other nested application relations found by grep: they peak at 50 arguments. - Limitations: the queries were not run against a live database; the *.real.test.ts tests were not verified without a local Docker; nothing was pushed or deployed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agentHits
force-pushed
the
fix/nested-application-column-limit
branch
from
October 6, 2026 18:24
e13b437 to
44ebb05
Compare
4 tasks done
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.
What is this PR about?
The
applicationtable has 101 columns. Drizzle 0.45 packs every selected column of a nested relation into onejson_build_array(...)call, and Postgres rejects calls with more than 100 arguments (54023 cannot pass more than 100 arguments to a function). Three queries in AgentHits-Dev still loaded the wholeapplicationrow through a nested relation:findDeploymentById(application,schedule.application,volumeBackup.application): now selects onlyserverId, the only field callers read. The error broke the deployment log WebSocket (it closed silently),deployment.readLogs,killProcess,removeDeployment, rolling back, and rollback creation during deploys with a rollback registry. Removing old rollbacks was skipped silently. Upstream had already narrowed this query (97885ee), but the upstream merge 5a1d8ea (2026-10-01) keptapplication: true.assertVolumeRestoreObjectBound):applicationandcomposenow select onlyappName. A volume restore could not start.monitoring-access:applicationnow selects onlyapplicationIdandserverId. This lookup runs for every app name that is not an application, so monitoring for compose services, databases and preview deployments failed (docker stats WebSocket,user.getContainerMetrics).A shared test helper,
apps/dokploy/__test__/helpers/postgres-function-args.ts, compiles the real SQL withdrizzle.mock({ schema })and countsjson_build_arrayarguments. Each of the three queries has a test.No migrations and no new environment variables; only the
dokployservice image changes.Checks
vitest run: 2055 pass, 1 skipped; the 8 failures are only in*.real.test.ts(no local Docker socket).bun run typecheck: 4/4 packages pass. SelectingappNameinstead ofserverIdin the narrowed relations makes tsc fail inlisten-deployment.ts, so typecheck guards the column lists.bun run format-and-lint: no errors.applicationfound by grep was compiled withtoSQL; they peak at 50 arguments.Rollout notes
dokployimage and take a database backup.deployment.readLogsreturns the log text, and monitoring opens for a compose service or a database.Not in this PR
backup.listBackupFilesfails with the same error in AgentHits-Dev; #6 fixes it. The two branches merge cleanly. The #6 test keeps its own copy of the argument counter, which can switch to the shared helper later.🤖 Generated with Claude Code