CLI task create/fork: check payload task_env locally and tidy up the --env check

Open
#74 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, go, python
Domain
backend, cli, testing

Research direction

Start with orcaster/cmd/task.go at buildTaskBody, runTaskCreate, and runTaskFork, then read the existing environment validators and server/tests/test_env_names_parity.py. Trace how Run in orcaster/cmd/root.go captures errors and requests, and use the shared fixture in Go and Python tests. Done means the acceptance criteria pass, including the CHANGELOG and README updates.

Written by the indexing model from the issue text.

Description

cli enhancement P3 question

Problem

orcaster task create and orcaster task fork check each --env entry locally before any request (orcaster/cmd/task.go:802-807, task.go:865-884). Some gaps remain.

  1. task_env inside --payload is not checked. buildTaskBody validates only the --env list (task.go:805). A credential typed in the payload, for example --payload '{"task_env":["NAME=value"]}', is sent to the server. The server answers 422 and does not echo it, but the value has already left the machine. The CLI README documents this as a known gap (orcaster/README.md:332-336).
  2. --env silently replaces the payload list. When both are given, pm["task_env"] = p.taskEnv overwrites the payload task_env with no message (task.go:824-826).
  3. task create accepts stray positional arguments. taskCreateCmd has no Args (task.go:96-100). --env NAME value (a value typed after the name) creates the task with NAME, ignores value and exits 0. cobra.NoArgs is not a safe fix, because its error message repeats the argument.
  4. The profile is loaded before the flags are checked. runTaskCreate and runTaskFork call newClient() before buildTaskBody (task.go:401-409, task.go:427-435). With no active profile, an invalid --env reports the profile error first.
  5. The --env help does not say how to get an empty strict list. --env '' fails the name check, so task_env: [] is only possible through --payload. The help text (task.go:176) does not say this. The comment "A PRESENT flag (even empty)" (task.go:809-810) is not accurate for --env.
  6. Nothing keeps the Go rules equal to the server rules. The Go regexes (task.go:847-854) mirror the server ones, and their comment still points to an old path (task.go:842-843). server/tests/test_env_names_parity.py compares the server with the worker, not with the CLI. orcaster/cmd/secret.go:127 reuses the same token-prefix rule for secret names.

The task_env count and length bounds in the CLI are tracked in a separate issue.

Proposed change

  1. Run validateTaskEnvEntries on payload.task_env when it is a list of strings. Report the position as payload.task_env[N], counted from 0 like the server. Never print the entry.
  2. Handle --env together with a payload task_env as decided in the open question below.
  3. Add an Args function to taskCreateCmd that rejects positional arguments with a fixed message, for example task create takes no positional arguments; did you mean --env NAME?. It never prints the argument.
  4. Call buildTaskBody before newClient() in both commands.
  5. Add to the --env help: use --payload '{"task_env":[]}' for an explicit empty list. Fix the comments at task.go:809-810 and task.go:842-843.
  6. Add one shared fixture of entries with the expected result (ok, token, name, orch). Run it from a Go test against validateTaskEnvEntries and the secret-name check, and from a Python test against the server validators.
  7. Add tests through Run (orcaster/cmd/root.go:48-65) that assert exit code 1, the error: ... line on stderr and zero requests.
  8. Update orcaster/README.md:325-340.

Compatibility

  • Every request that the server accepts today is still sent unchanged, as long as only one of --env and a payload task_env is given.
  • New local errors replace a server 422 that the same command already gets today: invalid payload entries, and positional arguments on create (which the CLI ignores today).
  • The only possible break is a script that passes both --env and a payload task_env and relies on --env winning. See the open question.

Acceptance criteria

  • orcaster task create and orcaster task fork with --payload '{"task_env":["NAME=value"]}' exit 1, send no request and print no part of the entry.
  • A valid payload task_env without --env is sent unchanged.
  • --env plus a payload task_env follows the decided behavior, with a test.
  • orcaster task create --payload '{}' --env NAME value exits 1, sends no request and does not print value.
  • With no active profile, an invalid --env or payload task_env reports the flag error, not the profile error.
  • The --env help explains the empty list, and the comments in task.go are correct.
  • A shared fixture passes in the Go and the Python suites. Changing one regex on either side makes a suite fail.
  • Tests through Run cover the stderr line and exit code 1.
  • Existing scripts that use --payload or --env alone keep working without changes.
  • CHANGELOG entry under Unreleased.

Open questions

  • --env together with a payload task_env:
    • Option A: print a warning to stderr and keep --env winning. Existing scripts keep working. The warning is easy to miss in logs.
    • Option B: exit with an error. Two sources for one field cannot be missed. It breaks scripts that rely on the override, so it needs a CHANGELOG note, or a warning for one release first.
      Option A keeps existing deployments and scripts working.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.