feat: v1.8.0 — mutation verbs honour --json / --jq / --template - #4
Merged
Merged
Conversation
`--json` silently did nothing on every state-changing command. They printed a status line straight to stdout and never went through `printData`, so a script doing `n8nctl workflow archive X --json | jq` got human text and failed to parse — with no error to say why. This was flagged in review of #3 and left as a follow-up because fixing it for `archive` alone would have made it the odd one out among the mutation verbs. 19 commands now route their result through a new `printMutation` helper: workflow activate/deactivate/archive/unarchive/delete/refresh/tag/transfer, tag create/update/delete, variable set/delete, execution delete, credential delete/transfer, user delete/role, project create/update/delete/add-user/ remove-user. --dry-run previews are machine-readable too, flagged "dryRun". ## Opt-in on purpose — this is NOT a breaking change printData's contract §2 says non-TTY is always JSON. Applying that here would have switched piped output to JSON for every existing caller, silently breaking any script that greps the status line. So printMutation deviates deliberately: with no output flag the status line still goes to stdout exactly as before, piped or not. Only an explicit --json/--jq/--template switches stdout to data, and then the human line moves to stderr so stdout stays pure. Full contract-§2 alignment remains available as a deliberate major-version decision; it is documented in the helper rather than smuggled in here. `printMutation` takes a PrintContext, not a Factory — lib/output.ts must not depend on factory.ts, which would close an import cycle of exactly the kind that caused the completion flake in #2. ## Verified - 511 tests (+9), coverage gate green, lint/build/audit clean. - The 502 pre-existing tests passed UNCHANGED, which is the empirical evidence for the non-breaking claim: the default path is untouched. - Live through the built CLI: no flag + pipe still emits text; --json pipes parseable JSON; --jq filters a field; the status line lands on stderr.
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.
Follow-up to the review finding on #3, done properly across all mutation verbs
instead of just
archive.The bug
--jsonsilently did nothing on every state-changing command. They wrote astatus line straight to stdout and never went through
printData:$ n8nctl workflow archive 58 --json | jq .id parse error: Invalid numeric literal at line 1, column 2No error, no signal — a script just gets
✓ archived workflow 58 "wf"where itexpected JSON. 19 commands now route their result through a new
printMutationhelper:
workflowactivate/deactivate/archive/unarchive/delete/refresh/tag/transfer,
tagcreate/update/delete,variableset/delete,execution delete,credentialdelete/transfer,userdelete/role,projectcreate/update/delete/add-user/remove-user.
--dry-runpreviews are machine-readable too, flagged"dryRun": true.Opt-in on purpose — NOT a breaking change
printData's contract §2 says non-TTY is always JSON. Applying that here wouldswitch piped output to JSON for every existing caller, silently breaking any
script that greps the status line. So
printMutationdeviates deliberately:--json/--jq/--templateFull contract-§2 alignment stays available as a deliberate major-version
decision; it's documented in the helper rather than smuggled in here.
printMutationtakes aPrintContext, not aFactory—lib/output.tsmust notdepend on
factory.ts, which would close an import cycle of exactly the kind thatcaused the completion flake fixed in #2.
Verified
for the non-breaking claim, since the default path is untouched.
--jsonpipesparseable JSON;
--jqfilters a field; the status line lands on stderr.🤖 Generated with Claude Code