Merged
Conversation
Allow reading JSON payload from a file instead of passing it inline.
Supports reading from stdin with '-' as the filename.
Examples:
kernel invoke myapp action -f payload.json
cat payload.json | kernel invoke myapp action -f -
echo '{"key": "value"}' | kernel invoke myapp action -f -
Address review feedback: ensure --payload "" still explicitly sets an empty payload, preserving the original behavior where the API can distinguish between "no payload" and "empty payload".
Add documentation for the new --payload-file / -f flag including: - Flag description in the commands reference - Usage examples showing file and stdin input
| if payloadStr != "" { | ||
| var v interface{} | ||
| if err := json.Unmarshal([]byte(payloadStr), &v); err != nil { | ||
| return "", false, fmt.Errorf("invalid JSON in payload file: %w", err) |
There was a problem hiding this comment.
Misleading error message for stdin JSON validation failure
Low Severity
When reading from stdin using -f -, the JSON validation error message says "invalid JSON in payload file" which is incorrect for stdin input. The read error messages correctly differentiate between stdin and file cases (lines 243 and 249), but the JSON validation error message at line 258 is shared and uses the file-specific wording. Users piping data via stdin will see a confusing error referencing a "payload file" that doesn't exist.
hiroTamada
approved these changes
Jan 8, 2026
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.
Summary
Add a
--payload-file/-fflag tokernel invokethat allows reading the JSON payload from a file instead of passing it inline. This is useful for:Usage
Details
--payloadand--payload-fileflags are mutually exclusive (enforced by cobra)-as a special filename to read from stdinTest plan
go build ./...passesgo test ./...passeskernel invoke app action -f payload.jsonecho '{}' | kernel invoke app action -f ---payloadand--payload-filecannot be used togetherNote
Adds file/stdin-based payload input to
kernel invokewith JSON validation and updates docs.--payload-file,-fflag ininvoke(mutually exclusive with--payload)getPayloadhelper supports reading from file or-(stdin), trims whitespace, and validates JSON before invokingWritten by Cursor Bugbot for commit d7205d5. This will update automatically on new commits. Configure here.