Reject three more doomed invocations before draining stdin

Merged
JE
3mo ago
+82-10

Follow-up to #641, which was squash-merged with eleven review threads still open. Eight of those described code the later commits on that branch had already changed; three were still live and are fixed here.

What was still live

comments create with an all-invalid target. The create loop deliberately tolerates individual bad IDs so a mixed batch still posts what it can, but when every comma-separated token is malformed the invocation creates nothing — and extractIDs is pure, so that is knowable from the argument alone. requireOneParseableTarget settles it before the read; the partial-success behavior for mixed batches is untouched.

An explicitly blank --subscribe. resolvePersonIDs skips blank tokens, so --subscribe "" can never resolve to anyone. rejectSubscribeConflict now decides that too, ahead of the read at docs documents create, messages create and schedule create. applySubscribeFlags still calls it, so the message stays in one place.

cards update --due. dateparse.Parse returns unrecognized input unchanged, so an unparseable due date failed only at the server — after the producer had been spent. It now rejects locally, as todos update already did, and the parsed value is carried forward rather than re-derived.

Why these matter

Same contract as #641: an invocation that is already doomed by its arguments must be rejected before stdin is drained. Otherwise the caller waits on a producer whose output is discarded, and a blank pipe answers "stdin is empty" instead of naming the real problem.

Tests

Six more cases in the tracking-reader table (42 total), each asserting the deterministic error, that stdin was never read, and that no request was issued. Two of the six pin orderings that were already correct but unpinned — chat update --room and cards create --card-table — so they cannot regress silently.

bin/ci green on top of merged main.


Summary by cubic

Rejects three more doomed invocations before reading stdin and closes two blank-value gaps, so callers aren’t blocked on discarded producer output. Previously these cases read stdin and failed late; now they fail fast with clear usage errors.

  • comments create: requireOneParseableTarget ensures at least one numeric recording ID in the comma-separated target; returns “no valid recording ID …” before any read. Partial success for mixed batches is unchanged.
  • docs/messages/schedule create: rejectSubscribeConflict also rejects explicitly blank or delimiter-only --subscribe, and still rejects --subscribe with --no-subscribe; evaluated before any read. The helper now takes the subscribe value; call sites updated.
  • cards update --due: parse once and validate as YYYY-MM-DD. Whitespace-only and unparseable values return “Invalid due date” locally. The parsed value is carried forward instead of re-parsing.
  • Tests: nine new tracking-reader cases (now 45 total), including pinned orderings for chat update --room and cards create --card-table, plus new cases for whitespace-only --due and delimiter-only/blank --subscribe.