[GH-ISSUE #157] Residual unknown CLI commands use unsafe schema bypassing casts #103

Closed
opened 2026-10-15 18:21:12 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @morluto on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/157

Symptom

src/cliUnknownCommands.ts builds inputs for unknown registry operations as object literals and then force-casts them to domain input types:

  • unknown-record payload uses as RecordUnknownInput.
  • unknown-update payload uses as unknown as UpdateUnknownInput.

This bypasses schema-driven validation at this layer and can hide contract drift between the CLI wiring and domain input requirements.

Evidence

  • src/cliUnknownCommands.ts:86 casts the record payload to RecordUnknownInput.
  • src/cliUnknownCommands.ts:123 casts the update payload with as unknown as UpdateUnknownInput.

Why this matters

The project uses explicit parsing at boundaries to enforce contracts. CLI command code should avoid assertion-based coercion here so schema changes or new required fields surface during local compile-time review instead of being hidden in runtime failures.

Suggested fix

  • Add boundary parsing with recordUnknownInputSchema.parse(...) and updateUnknownInputSchema.parse(...) in the command handlers.
  • Remove unsafe assertions and rely on parsed outputs.

Scope

Only src/cliUnknownCommands.ts (residual unknown CLI adapters).

Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/157 ## Symptom `src/cliUnknownCommands.ts` builds inputs for unknown registry operations as object literals and then force-casts them to domain input types: - `unknown-record` payload uses `as RecordUnknownInput`. - `unknown-update` payload uses `as unknown as UpdateUnknownInput`. This bypasses schema-driven validation at this layer and can hide contract drift between the CLI wiring and domain input requirements. ## Evidence - `src/cliUnknownCommands.ts:86` casts the record payload to `RecordUnknownInput`. - `src/cliUnknownCommands.ts:123` casts the update payload with `as unknown as UpdateUnknownInput`. ## Why this matters The project uses explicit parsing at boundaries to enforce contracts. CLI command code should avoid assertion-based coercion here so schema changes or new required fields surface during local compile-time review instead of being hidden in runtime failures. ## Suggested fix - Add boundary parsing with `recordUnknownInputSchema.parse(...)` and `updateUnknownInputSchema.parse(...)` in the command handlers. - Remove unsafe assertions and rely on parsed outputs. ## Scope Only `src/cliUnknownCommands.ts` (residual unknown CLI adapters).
bsakaguchi 2026-10-15 18:21:12 +00:00
Author
Owner

@morluto commented on GitHub (Jul 17, 2026):

Superseded by removal of cliUnknownCommands.ts. Current residual-unknown inputs are parsed with listUnknownsInputSchema, recordUnknownInputSchema, updateUnknownInputSchema, and verifyUnknownResolutionInputSchema at the MCP boundary.

<!-- gh-comment-id:5001297261 --> @morluto commented on GitHub (Jul 17, 2026): Superseded by removal of cliUnknownCommands.ts. Current residual-unknown inputs are parsed with listUnknownsInputSchema, recordUnknownInputSchema, updateUnknownInputSchema, and verifyUnknownResolutionInputSchema at the MCP boundary.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#103
No description provided.