Skip to content

feat(package): add import-selection command for project packages - #35

Merged
SomeoneWithOptions merged 1 commit into
mainfrom
feat/package-import-selection
Oct 22, 2026
Merged

SomeoneWithOptions merged 1 commit into
mainfrom
feat/package-import-selection

Conversation

@SomeoneWithOptions

Copy link
Copy Markdown
Owner

What / why

Upstream spec 1.1.1 adds importPackageSelection (POST /n8n-packages/import-selection), a beta endpoint. Where package import brings in a whole package, this one picks individual workflows from one source project of a project package. The CLI had no command for it, and the manifest listed it as planned in phase 30.

Changes

  • New command n8n package import-selection (Track A):
    • Flags: --file FILE|-, --project-id, repeatable --workflow-id / --delete-workflow-id, --workflow-conflict-policy, --workflow-id-policy, --overwrite-deletion-policy, --yes, --output.
    • Workflows land in the instance project with the same ID as the source project, which is created if it doesn't exist. There is no target-project flag.
    • The import is additive. It deletes only the IDs passed to --delete-workflow-id.
  • Client ImportPackageSelection:
    • selectedWorkflowIds is always sent as a JSON-encoded string array, [] for a delete-only run.
    • deletedWorkflowIds is sent only when non-empty.
    • Unset conflict and deletion policies are left out so the server defaults apply. workflowIdPolicy is always sent, as package import does.
  • Validated locally, before any request:
    • The source project is required, and at least one import or delete ID must be given.
    • Empty or padded IDs are rejected, as are duplicates and the same ID in both lists (the server's workflow-removal-conflict).
    • Policy values must be valid, and --overwrite-deletion-policy without --delete-workflow-id is rejected.
  • Confirmation (always asks):
    • The prompt names the project ID (created if missing), how many workflows are imported, and which IDs get archived.
    • hard-delete gets a stronger prompt that says the deletion is permanent and takes executions with it.
    • --file - requires --yes.
  • Errors restate the fix:
    • 409: removal conflict or conflict policy.
    • 422: workflow-removal-forbidden → needs workflow:delete.
    • 400: the endpoint needs a project package → n8n package export --project-id.
    • 403: names workflow:import, plus workflow:delete when deleting.
  • Refactor: ImportPackage and ImportPackageSelection share one multipart transport. Form fields are now written in sorted order, so the request body is the same on every run. The result rendering and newImportBlockedError(path) are reused.
  • Manifest: importPackageSelection is now implemented, and deliveredThrough goes from 29 to 30. Docs are regenerated.

Verification

  • Spec-derived: everything about the request and response shape comes from openapi.upstream.yml 1.1.1 (~7489). That covers the field names, JSON-string arrays, enums, the 409/422 issue bodies, and the 400 for workflow packages.

  • Not live-verified. No call was made against an instance.

  • Client httptest covers:

    • multipart field names and values
    • [] for delete-only, and unset fields left out
    • validation before transport
    • 409/422 issues kept verbatim with the selection path
    • 400/403/404
    • cancellation
  • CLI in-process tests cover refusal before transport, --file - requiring --yes, input validation, the hard-delete prompt, error hints, and text/JSON output.

  • Integration tests:

    • Read-only: a malformed archive must come back as 400 or 422.
    • Destructive, gated on N8N_INTEGRATION_DESTRUCTIVE=1: creates an n8n-cli-test- project with two workflows and registers cleanup first. It exports the project, imports one workflow, archives the other, then re-runs through the CLI with skip. The test skips on 403/404/503.
  • make check passes locally (after rebasing on fix: core resource spec drift (evaluation, workflow, credential, data-table, project, variable, folder) #33 and ci: skip checks for docs-only pull requests #34)

  • go test -race -shuffle=on -count=1 ./... passes

  • make docs run (new docs/n8n_package_import-selection.md)

  • No secrets/keys/tokens in diff or logs

  • No v* tag or release commit in this PR

Notes for reviewer

  • Same ID in both --workflow-id and --delete-workflow-id is refused locally. Under --workflow-id-policy source the server answers 409 for it. Under new the server might accept it, but it's almost certainly a mistake. Easy to relax if we'd rather let the server decide.
  • --workflow-conflict-policy is optional here (server default new-version). It is required on package import. The prompt shows the default it will use.
  • Archives stream with no 1 MiB cap, the same as package import. The server enforces N8N_ENDPOINTS_PAYLOAD_SIZE_MAX (16 MB by default).
  • The spec's idempotencyKey parameter on this op is left for the idempotency-key branch (12).
  • Merge order for wave 2 is 09 (this PR) → 10 → 11, because TestPhaseCounts requires phases to be delivered in order.

🤖 Generated with Claude Code

@SomeoneWithOptions
SomeoneWithOptions merged commit b23df05 into main Oct 22, 2026
5 checks passed
@SomeoneWithOptions
SomeoneWithOptions deleted the feat/package-import-selection branch October 22, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant