akash-network / akash-network/console
perf(api): add max length constraints to Zod schemas for body fields
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 264
- Forks
- 94
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 297
Description
Problem
Several Zod schemas used to validate request bodies lack .max() constraints on string and array fields. Even with a body size limit, unbounded schemas allow expensive validation passes on large inputs.
Affected Schemas
| Schema | Field | File | Issue |
|---|---|---|---|
SignTxRequestInputSchema |
messages array |
src/billing/http-schemas/sign-tx.schema.ts |
.min(1) but no .max() |
PricingSpecsSchema |
root array | src/pricing/http-schemas/pricing.schema.ts |
z.array(...) with no .max() |
| Deployment create | sdl: z.string() |
src/deployment/http-schemas/deployment.schema.ts |
No .max() on SDL string |
| Deployment update | sdl + certificate |
src/deployment/http-schemas/deployment.schema.ts |
No .max() on either field |
bio |
src/routers/userRouter.ts |
No max length on bio field | |
| User template | sdl, title |
src/routers/userRouter.ts |
No max length on either field |
Suggested Fix
Add appropriate .max() constraints:
// Example for pricing
z.array(PricingSpecsSchema).max(50)
// Example for SDL
z.string().max(1_000_000) // 1MB max SDL
// Example for bio
z.string().max(500)
// Example for messages
messages: z.array(messageSchema).min(1).max(100)
Files
apps/api/src/billing/http-schemas/sign-tx.schema.tsapps/api/src/pricing/http-schemas/pricing.schema.tsapps/api/src/deployment/http-schemas/deployment.schema.tsapps/api/src/routers/userRouter.ts
Context
Part of the API event loop performance audit.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the schemas in apps/api/src/billing/http-schemas/sign-tx.schema.ts and apps/api/src/deployment/http-schemas/deployment.schema.ts, then inspect the user template fields in apps/api/src/routers/userRouter.ts. Determine suitable maximums for the remaining messages, SDL, certificate, and title fields; done means those request-body fields enforce explicit limits without changing unrelated schemas.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100