task_env bounds: CLI skips them, a length error masks the credential diagnostic, tests are thin

Open
#44 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
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, go, python
Domain
api, backend

Research direction

Start with orcaster/cmd/task.go:856-884 and server/orcaster_server/env_names.py:183-197, then read the manual at docs/user-manual.md:1748-1750 and the route tests named in the issue. Trace the task insert paths and the fork flow at server/orcaster_server/api/admin_tasks.py:1964. Done means the checklist's validation, route and stored-row coverage, documentation, bounds decision, and Unreleased changelog entry are addressed.

Written by the indexing model from the issue text.

Description

cli enhancement P3 server

Problem

The server limits payload.task_env to 256 entries and 128 characters per name (server/orcaster_server/env_names.py:22-23, :183-192). Some follow-ups remain. Each is independent, so this issue is a checklist.

  • The CLI does not apply the bounds. validateTaskEnvEntries (orcaster/cmd/task.go:865-884) checks only the token prefix, the name shape and the ORCH_ prefix. Its comment says it applies the same rules in the same order as the server (task.go:856-858). orcaster task create --env with 257 valid names, or with a name of 129 characters, passes the local check, sends the request and gets a 422. No value leaks, but the local check is incomplete.
  • Length is checked before the token prefix. env_names.py:188-192 checks length, then :193-197 the token prefix. An entry that starts with a known token prefix and is longer than 128 characters gets "longer than 128 characters" and not the "looks like a credential" message. The user manual documents this order (docs/user-manual.md:1748-1750), so a change must update that text. Neither message echoes the entry.
  • Enforcement is at model construction. The validators run when the request models are built (server/orcaster_server/schemas/tasks.py:330, :581; server/orcaster_server/api/admin_workers.py:173). The code that inserts rows takes an already built payload. There are several INSERT INTO tasks statements (server/orcaster_server/api/admin_tasks.py:107, :149, :2097; server/orcaster_server/api/admin_workers.py:137). A future caller that builds a payload without the model would skip the bound.
  • Route tests are thin. Only POST /api/v1/tasks has a route test for oversize task_env (server/tests/test_api_v1_tasks_lifecycle.py:344-359). The worker command and control-op routes test shape errors but not size (server/tests/test_worker_command_task_env_validation.py:112-136).
  • Stored rows over the bound are not pinned. Rows stored before the bound are still served. A fork of such a row builds a new request through merge_fork_params (server/orcaster_server/api/admin_tasks.py:1964) and gets a 422 until task_env is overridden. This is not tested or documented.
  • egress_allowlist has no size bound. validate_payload_egress_allowlist checks only the shape (env_names.py:228-248).
  • Cosmetic. The length message ends with "declare the variable name only" (env_names.py:189-192), the same hint as the other messages. Say that names are at most 128 characters.

Proposed change

  • Add the count and length constants to the Go validator, in the same order as the server, with a parity test.
  • Move the length check after the token-prefix check and before the shape check, and update the manual sentence.
  • Either call validate_payload_task_env defensively in the insert helpers, or add a test that lists INSERT INTO tasks under server/orcaster_server and fails for a site not in an explicit list of validated paths.
  • Add oversize route tests (257 entries, a 129-character name) for create, fork, worker command and control-op routes.
  • Add a test and a doc sentence for stored over-bound rows: still delivered to workers; a fork returns 422 until task_env is overridden.
  • Decide whether egress_allowlist gets a count and length bound, or record that the request body cap is the limit.

Acceptance criteria

  • orcaster task create and orcaster task fork reject 257 --env names and a 129-character name locally, exit non-zero, send no request, and print no part of the entry.
  • An entry with a known token prefix and over 128 characters is reported as credential-like and the message does not echo it.
  • A test or a defensive call guarantees that every INSERT INTO tasks path validates task_env.
  • Oversize route tests exist for the create, fork, worker command and control-op routes.
  • A test pins "a stored over-bound row is still delivered; its fork returns 422 until task_env is overridden".
  • The decision on egress_allowlist bounds is recorded.
  • Valid requests and stored rows behave as today: existing deployments keep working without config changes.
  • CHANGELOG entry under Unreleased.
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.