feat: add safe application env upsert#4581
Open
agentHits wants to merge 1 commit into
Open
Conversation
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?
This PR adds a safe partial environment variable upsert endpoint for applications. API and MCP clients can now add or update selected application environment variables without reading or replacing the full env block, which avoids deleting existing secrets when the current env is redacted.
The new
application.env.upsertmutation reads the current env server-side, merges submitted variables by key, and returns metadata only. It supportsdryRun, optionalexpectedRevisionconflict protection, and optionalredeploywhen the caller also has deployment permission.Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
Closes #4525
Screenshots (if applicable)
Verification
corepack pnpm --filter=dokploy exec vitest run --config __test__/vitest.config.ts __test__/env/upsert.test.ts __test__/env/application-env-upsert.test.tscorepack pnpm exec biome check apps/dokploy/server/api/routers/application.ts packages/server/src/db/schema/application.ts packages/server/src/index.ts packages/server/src/services/application.ts packages/server/src/utils/env-upsert.ts apps/dokploy/__test__/env/upsert.test.ts apps/dokploy/__test__/env/application-env-upsert.test.tscorepack pnpm --filter @dokploy/server run typecheckcorepack pnpm --filter=dokploy run typecheckcorepack pnpm --filter=dokploy run generate:openapiPOST /application.env.upsertis exposed.Note: I did not commit
openapi.jsonbecause the repository has a post-mergeGenerate and Sync OpenAPIworkflow that regenerates and syncs the OpenAPI artifact to Dokploy, MCP, CLI, SDK, and docs repositories after changes land oncanary.