Repository navigation
feat(promotion): add environment apply/promote and n8n 2.46 project sync fields - #45
Merged
Merged
Conversation
…ync fields n8n 2.46 replaced connections with environments. Add 'n8n promotion environment apply|apply-continue|promote' for the three phase-36 operations and teach the project sync routes the 2.46 shapes while keeping 2.45 instances working. - Environment apply/apply-continue reuse the selection command: expected source flags or --expected-from, --input, confirmation, exit codes 0/3/4/1, and idempotency keys. Promote mirrors 'promotion promote' with an optional commit message, as the 2.46 spec allows. - expectedSource carries environmentId (2.46) or configId (2.45), never both. Project apply/apply-continue add --expected-environment-id, mutually exclusive with --expected-config-id; --expected-from passes through whichever ID the instance returned. - Results model environmentId next to connectionId/configId, the new folder/workflow/credential counts as optional, and promote review and warnings. Warnings go to stderr; JSON stays verbatim. - Help no longer says apply/promote need connections on 2.46; provider help follows the spec's environment wording. - Manifest: phase 36 implemented; deliveredThrough raised to 36. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 / why
n8n 2.46.4 replaced
/promotions/connectionswith/promotions/environments. #44 added environment management but left whole-instance sync addressing connections, and project sync still assumed the 2.45 field names. This PR finishes the migration: environment apply/apply-continue/promote, plus 2.46 request/response fields on the project sync routes. Every changed command keeps working against 2.45 instances.Changes
implemented,deliveredThrough= 36):n8n promotion environment apply <environment-id>→POST /promotions/environments/{id}/applyn8n promotion environment apply-continue <environment-id>→POST .../apply/continuen8n promotion environment promote <environment-id>→POST .../promoteenvironment, next toconnect/disconnectfrom feat(promotion): add promotion environments #44, because they take an environment ID and exist only on 2.46. The top-levelpromotion apply|apply-continue|promotestay connection-only (retired, for ≤2.45), so neither generation's command changes meaning.--expected-from,--expected-environment-id/--expected-branch/--expected-commit,--input,--confirm-destructive-changes), so the confirmation, stdin--yesrule, exit codes 0/3/4/1 and next-step hints match the connection versions. Unlike the connection apply, the environment apply takes an optionalexpectedSource, so it gets the expected-source flags.promotion promote(--force,--yes,--idempotency-key,--output). The one difference:--commit-messageis optional, because the 2.46 spec madecommitMessageoptional.configIdis refused locally, and the error explains it came from ≤2.45.expectedSourcemodelsconfigIdandenvironmentId, both optional. Exactly one must be set, and it is sent as given.--expected-environment-id(2.46) next to--expected-config-id(2.45). The two flags are mutually exclusive, validated locally, and the error says which one each n8n version needs.--expected-frompasses through whichever ID thechangesJSON or blocked result contains. A file with both IDs is refused.apply-continuerefuses anenvironmentIdsource and points atenvironment apply-continue.environmentIdis modelled next toconnectionId/configIdon apply, continue, changes and promote results, and text output prints whichever is present (Environment:orConfig:).folders.updated/moved/renamed,workflows.moved,credentials.updated) are*intand render only when the instance sends them, so a 2.45 result never shows invented zeros.--output jsonis lossless for both shapes).review(reviewId,number,webUrl) renders asReview: #N URL.warnings(message, optionallinkUrl) are advisory, since the push already happened, so they go to stderr in both output formats.gitConnection:pull, environment promote →gitConnection:push.--force.promotiongroup help no longer says apply/promote still address connections.TestPromotionProjectChangesnow acceptssource.environmentIdorsource.configId.Verification
make checkwith the 2.46.4 spec present asopenapi.upstream.yml: green (fmt-check, vet, staticcheck all, test, test-race, cross for 5 targets, tidy-check, govulncheck: "No vulnerabilities found.")make docs: regenerated; three new pages underdocs/.New client tests (
internal/n8n/promotion_environment_sync_test.go): paths and bodies for the three routes, with and withoutexpectedSourceandcommitMessage; error statuses; refusals before any request (bad UUID,configIdsource, both IDs, short commit, blank/long commit message, connection continue with anenvironmentIdsource); project apply/continue with both source variants; old- and new-shape decoding of apply, promote and changes; verbatim re-encoding. Idempotency header cases were added for all three routes.New CLI tests (
internal/cli/promotion_environment_sync_test.go): JSON and text output, new count rows (and their absence for 2.45), blocked/source-changed/unknown exit codes and hints, interactive decline and non-interactive refusal with zero requests, stdin--yesrule, flag exclusivity with per-version error text,--expected-frompassthrough for both generations, promote review and warnings on stderr, 404/403/409/400/422 messages, and group help. The three commands were also added toTestIdempotencyKey*(header only when set, invalid key refused before any request).make checkpasses locallymake docsrun if CLI help changed (docs/README.md updated)No secrets/keys/tokens in diff or logs
No
v*tag or release commit in this PR (maintainer releases separately)Notes for reviewer
openapi.upstream.yml, 2.45.7 outside the repo for the diff.🤖 Generated with Claude Code