Skip to content

Commit fe432f9

Browse files
committed
chore(api): tidy dead-code and bounds cleanup
1 parent 932c688 commit fe432f9

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

apps/sim/app/api/v2/lib/response.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,18 @@ export function decodeCursor<T = Record<string, unknown>>(cursor: string): T | n
166166
* Reads back an offset cursor minted by `encodeCursor({ offset })`.
167167
*
168168
* An absent cursor means page one. A cursor that is not valid base64-JSON, or
169-
* that does not carry a non-negative integer `offset`, is REJECTED rather than
169+
* that does not carry a non-negative integer `offset`, is rejected rather than
170170
* coerced to 0: silently restarting at page one while the caller believes it is
171-
* paging forward makes a paging client loop over the first page forever.
172-
*
173-
* Throwing an `OrchestrationError('validation')` is what the other v2 cursor
174-
* lists do, and the v2 error policies render it as the canonical 400.
171+
* paging forward makes a paging client loop over the first page forever. The v2
172+
* error policies render the thrown validation error as the canonical 400.
175173
*/
176174
export function decodeOffsetCursor(cursor: string | undefined): number {
177175
if (!cursor) return 0
178-
const decoded = decodeCursor<{ offset?: unknown }>(cursor)
179-
if (!decoded || !Number.isInteger(decoded.offset) || (decoded.offset as number) < 0) {
176+
const offset = decodeCursor<{ offset?: unknown }>(cursor)?.offset
177+
if (typeof offset !== 'number' || !Number.isInteger(offset) || offset < 0) {
180178
throw new OrchestrationError('validation', 'Invalid cursor')
181179
}
182-
return decoded.offset as number
180+
return offset
183181
}
184182

185183
/**

apps/sim/lib/folders/queries.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,10 @@ interface ListActiveFolderRowsOptions {
174174
* Materializes the workspace's active folder tree for one resource type.
175175
*
176176
* The read is always bounded: `maxRows` defaults to `MAX_FOLDERS_PER_WORKSPACE`,
177-
* the same ceiling folder creation refuses to cross, so a workspace can never
178-
* legitimately hold more rows than a default call will accept. Exceeding the
179-
* bound THROWS `FolderCollectionLimitExceededError` — the index is never
180-
* silently truncated, because a partial path index resolves real folder paths
181-
* to `undefined` and re-roots resources at the workspace root.
177+
* the same ceiling folder creation refuses to cross, so a legitimate workspace
178+
* never trips it. Exceeding the bound throws `FolderCollectionLimitExceededError`
179+
* rather than truncating, because a partial path index resolves real folder
180+
* paths to `undefined` and re-roots resources at the workspace root.
182181
*/
183182
export async function loadActiveFolderPathIndex(
184183
workspaceId: string,

0 commit comments

Comments
 (0)