Skip to content

Add new flags for encoding and file input in activity complete and fail.#1072

Draft
ks-temporal wants to merge 2 commits into
temporalio:mainfrom
ks-temporal:ks/ACT-794-meta-encoding
Draft

Add new flags for encoding and file input in activity complete and fail.#1072
ks-temporal wants to merge 2 commits into
temporalio:mainfrom
ks-temporal:ks/ACT-794-meta-encoding

Conversation

@ks-temporal
Copy link
Copy Markdown

@ks-temporal ks-temporal commented Jun 1, 2026

Related issues

Addresses #954

What changed?

In activity complete, add new result-meta, result-file, result-base64
options to set encoding and/or supply result from a file.

In activity fail, add new detail-meta, detail-file, detail-base64 options
to set encoding and/or supply failure detail from a file.

Similar to input and input-file flags for other commands, only one of
result or result-file can be used, and at most one of detail or detail-file
can be used.

Checklist

Stability

  • Breaking changes are marked with 💥 in the PR title and release notes
  • Changes to JSON output (-o json / -o jsonl) are treated as breaking changes

Design

  • This feature does not depend on Cloud-only APIs or behavior (it works against an OSS server)
  • New commands follow temporal <noun> <verb> structure (e.g. temporal workflow start)
  • New flags are named after the API concept, not the implementation mechanism (good: --search-attribute, bad: --index-field)
  • New flags don't duplicate an existing flag that serves the same purpose
  • New flags do not have short aliases without strong justification
  • Experimental features are marked with (Experimental) in commands.yaml

Help text (see style guide at the top of commands.yaml)

  • All flags shown in help text and examples are implemented and functional
  • Summaries use sentence case and have no trailing period
  • Long descriptions end with a period and include at least one example invocation
  • Examples use long flags (--namespace, not -n), one flag per line
  • Placeholder values use YourXxx form (YourWorkflowId, YourNamespace)

Behavior

  • Results go to stdout; errors and warnings go to stderr
  • Error messages are lowercase with no trailing punctuation

Tests

  • Added functional test(s) (SharedServerSuite)
  • Added unit test(s) (func TestXxx) where applicable

Manual tests

The manual test below uses standalone activity, and tests the new flags in
activity complete and activity fail commands.

Setup

Start the server, assume worker for task queue YourTaskQueue is running,
start a standalone activity.

temporal server start-dev --headless
temporal activity start \
    --type YourActivityType \
    --task-queue YourTaskQueue \
    --activity-id YourActivityId \
    --start-to-close-timeout 10s

Running execution:
  ActivityId  YourActivityId
  RunId       <your-run-id>
  Namespace   default

Happy path
Note the RunId value, <your-run-id>, in the output above, as it is used in
each of the test path below.

  1. complete with result-meta.
$ temporal activity complete \
    --activity-id YourActivityId \
    --run-id <your-run-id> \
    --result "Hello World" \
    --result-meta binary/plain
$ temporal activity result \
    --activity-id YourActivityId \
    --run-id <your-run-id>

 Results:
  Status  COMPLETED
  Result  "SGVsbG8gV29ybGQ="
  1. complete with result-meta and result-base64.
$ temporal activity complete \
    --activity-id YourActivityId \
    --run-id <your-run-id> \
    --result "SGVsbG8AV29ybGQ=" \
    --result-meta binary/plain \
    --result-base64
$ temporal activity result \
    --activity-id YourActivityId \
    --run-id <your-run-id>

 Results:
  Status  COMPLETED
  Result  "SGVsbG8AV29ybGQ="

TODO: To use result-base64 without result-meta, we need to fix in CreatePayloads.

  1. Complete with result-meta and result-file.
$ echo -e -n "Hello\x00World" > in.bin
$ temporal activity complete \
    --activity-id YourActivityId \
    --run-id <RunId-from-above> \
    --result-file in.bin \
    --result-meta "encoding=binary/plain"
$ temporal activity result \
    --activity-id YourActivityId \
    --run-id <your-run-id>

Results:
  Status  COMPLETED
  Result  "SGVsbG8AV29ybGQ="

or

  1. Fail with detail, detail-meta and detail-base64.
$ temporal activity fail \
    --activity-id YourActivityId \
    --run-id <RunId-from-above> \
    --detail "AAECAwo="
    --detail-meta "encoding=binary/plain"
    --detail-base64

$ temporal activity result \
    --activity-id YourActivityId \
    --run-id <RunId-from-above> \
    --output jsonl

{"activityId":"YourActivityId",...,"status":"FAILED",... "data":"AAECAwo="...}
Error: activity failed

TODO: The other values for result-meta and detail-meta, e.g., binary/protobuf and
json/protobuf, are also supported, but require compiled protobuf files, or a new
option of --output raw in activity result to verify via CLI.

Error case

  1. Only one of result or result-file is allowed. Use in.bin from the above steps.
$ temporal activity complete \
    --activity-id YourActivityId \
    --run-id <RunId-from-above> \
    --result "Hello World" \
    --result-file in.bin

Error: provide exactly one of result or result-file
$ echo $?
1
  1. At most one of detail or detail-file is allowed.
$ temporal activity fail \
    --activity-id YourActivityId \
    --run-id <RunId-from-above> \
    --detail "Hello World" \
    --detail-file in.bin

Error: provide one of detail or detail-file, but not both

Composition

$ temporal activity complete ... --result ... --result-meta ...
$ temporal activity complete ... --result ... --result-meta ... --result-base64
$ temporal activity complete ... --result-file ... --result-meta ...
$ temporal activity complete ... --result ... --result-base64

$ temporal activity fail ... --detail ... --detail-meta ...
$ temporal activity fail ... --detail ... --detail-meta ... --detail-base64
$ temporal activity fail ... --detail-file ... --detail-meta ...
$ temporal activity fail ... --detail ... --detail-base64

In activity complete, add new result-meta, result-file, result-base64
to set encoding and/or supply result from a file.

In activity fail, add new detail-meta, detail-file, detail-base64
to set encoding and/or supply failure detail from a file.

Similar to input and input-file flags for other commands, only one
of result or result-file can be used, and atmost one of detail or
detail-file can be used.
Nul character in command line will work from go test files,
but not from Unix command line.

Also added additional check of result after activity complete.
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