Problem
The frontend enforces content length (500-10,000 chars) and title length (60 chars), but the CLI and API indexer have NO validation. Via CLI or direct contract calls, users can:
- Create storylines with arbitrarily long titles
- Submit 1-character "stories" or 1MB stories
- Only contract-level check is non-empty title + valid CID format
Current validation by layer
| Layer |
Title |
Content min |
Content max |
| Smart contract |
Non-empty only |
None |
None |
| Frontend |
60 chars ✓ |
500 chars ✓ |
10,000 chars ✓ |
| CLI |
Non-empty only ✗ |
Non-empty only ✗ |
None ✗ |
| API indexer |
None |
None |
None |
Fix
1. CLI validation (`packages/cli/src/sdk/client.ts`)
Import and use the shared constants from `lib/content.ts`:
- `createStoryline()`: validate `title.length <= 60`, `content.length >= 500`, `content.length <= 10000`
- `chainPlot()`: validate `content.length >= 500`, `content.length <= 10000`
- Show clear error messages: "Title must be 60 characters or less", "Content must be between 500 and 10,000 characters (currently: X)"
2. API indexer validation (soft — don't reject, but flag)
The API indexers process on-chain events that already succeeded — we can't reject them. But we can:
- Log a warning for out-of-bounds content
- Consider adding a `flagged` column or `hidden = true` for storylines that violate limits (created via direct contract calls)
This is optional — the CLI validation is the priority since that's the programmatic entry point we control.
Constants
```typescript
const MAX_TITLE_LENGTH = 60;
const MIN_CONTENT_LENGTH = 500;
const MAX_CONTENT_LENGTH = 10_000;
```
These already exist in `lib/content.ts` — the CLI should either import them or define matching constants.
Branch
`task/670-cli-content-validation`
Self-Verification (T3)
Problem
The frontend enforces content length (500-10,000 chars) and title length (60 chars), but the CLI and API indexer have NO validation. Via CLI or direct contract calls, users can:
Current validation by layer
Fix
1. CLI validation (`packages/cli/src/sdk/client.ts`)
Import and use the shared constants from `lib/content.ts`:
2. API indexer validation (soft — don't reject, but flag)
The API indexers process on-chain events that already succeeded — we can't reject them. But we can:
This is optional — the CLI validation is the priority since that's the programmatic entry point we control.
Constants
```typescript
const MAX_TITLE_LENGTH = 60;
const MIN_CONTENT_LENGTH = 500;
const MAX_CONTENT_LENGTH = 10_000;
```
These already exist in `lib/content.ts` — the CLI should either import them or define matching constants.
Branch
`task/670-cli-content-validation`
Self-Verification (T3)