Skip to content

fix(nodejs): narrow required route parameters#125

Open
ShuoRen-TT wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
ShuoRen-TT:agent/narrow-required-route-params
Open

fix(nodejs): narrow required route parameters#125
ShuoRen-TT wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
ShuoRen-TT:agent/narrow-required-route-params

Conversation

@ShuoRen-TT

@ShuoRen-TT ShuoRen-TT commented Jul 9, 2026

Copy link
Copy Markdown

Summary

  • derive a typed IdParamContext from the existing IdParamSchema
  • read route IDs through c.req.valid("param") in checkout, order, and simulation handlers
  • remove all 12 string | undefined TypeScript errors without non-null assertions or duplicate validation
  • add focused tests for present and missing route IDs

Root cause

The route handlers were declared with a generic Hono Context, so c.req.param("id") was typed as string | undefined. Although every affected route already uses zValidator("param", IdParamSchema, ...), that validated input type did not flow into the separately declared class handlers.

This change makes the handler context carry the Zod-derived parameter input/output type and consumes the value from Hono's validated request data.

Validation

  • changed-file strict TypeScript check: passed
  • focused route-ID tests: passed, 2/2
  • Hono runtime smoke test: GET /items/item-123 returned 200 with {"id":"item-123"}
  • Prettier, codespell, whitespace, and private-key checks: passed
  • this branch removes all 12 route-parameter errors; the only remaining standalone npm run build errors are the 8 discovery-profile errors fixed by fix(nodejs): align discovery profile registries #123
  • combined verification with fix(nodejs): align discovery profile registries #123:
    • npm run build: passed
    • npm test: passed, 3/3 tests

Related work

This PR is independently mergeable and fixes all route-parameter typing
errors. The current main branch still has separate discovery-profile type
errors tracked by #114 and fixed by #123. With both changes present,
npm run build and npm test pass.

Closes #124

@ShuoRen-TT ShuoRen-TT force-pushed the agent/narrow-required-route-params branch from 1116fd9 to 952b0fd Compare July 9, 2026 22:57
@ShuoRen-TT ShuoRen-TT marked this pull request as ready for review July 9, 2026 23:03
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Signal that the PR is ready for human triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Node.js sample fails npm run build because route params are typed optional

2 participants