Priority
P1
Problem
Generated RPC clients interpolate path parameters directly into URL templates. Values containing /, spaces, ?, #, %, or other reserved characters can change the route path or query boundary instead of being treated as a single path segment.
Evidence
packages/rpc-codegen/src/libs/generate.ts builds path expressions by replacing :${paramName} with ${input.path.${paramName}}.
packages/rpc-codegen/src/tests/codegen.spec.ts currently expects const path = \/users/${input.path.id}`;`.
packages/rpc-codegen/src/tests/e2e.spec.ts also asserts direct interpolation for /users/:id.
- Route path schemas are extracted from
@Param in packages/protocols-core/src/libs/schemaBuilder.ts, so path parameters are first-class generated inputs.
Desired outcome
Generated clients preserve route semantics by percent-encoding path segment values before building URLs.
Proposed implementation path
- Update path expression generation to wrap each path parameter with
encodeURIComponent(String(...)) or a small generated helper.
- Keep type generation unchanged; serialization should happen only in the generated request path.
- Add tests for path values containing
/, spaces, and URL-reserved characters.
- Update existing expectations that currently assert raw interpolation.
Acceptance criteria
- Generated clients encode each path parameter before interpolation.
- Existing query serialization remains separate from path construction.
- Round-trip tests prove an input like
{ path: { id: "a/b c" } } calls /users/a%2Fb%20c, not /users/a/b c.
- Generated clients still compile without importing runtime dependencies.
Validation
pnpm test --filter=@croco/rpc-codegen
pnpm typecheck --filter=@croco/rpc-codegen
pnpm build --filter=@croco/rpc-codegen
Scope boundaries
- This issue is limited to path segment encoding.
- It does not change query parameter serialization or body serialization.
- It does not introduce a configurable URL builder.
Priority
P1
Problem
Generated RPC clients interpolate path parameters directly into URL templates. Values containing
/, spaces,?,#,%, or other reserved characters can change the route path or query boundary instead of being treated as a single path segment.Evidence
packages/rpc-codegen/src/libs/generate.tsbuilds path expressions by replacing:${paramName}with${input.path.${paramName}}.packages/rpc-codegen/src/tests/codegen.spec.tscurrently expectsconst path = \/users/${input.path.id}`;`.packages/rpc-codegen/src/tests/e2e.spec.tsalso asserts direct interpolation for/users/:id.@Paraminpackages/protocols-core/src/libs/schemaBuilder.ts, so path parameters are first-class generated inputs.Desired outcome
Generated clients preserve route semantics by percent-encoding path segment values before building URLs.
Proposed implementation path
encodeURIComponent(String(...))or a small generated helper./, spaces, and URL-reserved characters.Acceptance criteria
{ path: { id: "a/b c" } }calls/users/a%2Fb%20c, not/users/a/b c.Validation
pnpm test --filter=@croco/rpc-codegenpnpm typecheck --filter=@croco/rpc-codegenpnpm build --filter=@croco/rpc-codegenScope boundaries