Skip to content

Commit 4d644af

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(oracle-fusion): validate continuing page totals
1 parent fc2d2ea commit 4d644af

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

apps/sim/lib/internal/oracle-fusion/protocol.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ describe('parseOracleFusionCollection', () => {
6666
it.each([
6767
{ items: [], count: 0, hasMore: false, limit: 25, offset: 5, totalResults: 6 },
6868
{ items: [{}], count: 1, hasMore: false, limit: 25, offset: 5, totalResults: 7 },
69-
])('rejects terminal pagination metadata while results remain %#', (value) => {
69+
{ items: [{}], count: 1, hasMore: true, limit: 25, offset: 5, totalResults: 6 },
70+
])('rejects pagination metadata that contradicts total results %#', (value) => {
7071
expect(() => parseOracleFusionCollection(value, (item) => item)).toThrow(
7172
'hasMore contradicts totalResults'
7273
)

apps/sim/lib/internal/oracle-fusion/protocol.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export function parseOracleFusionCollection<T>(
9090
if (totalResults !== undefined && !envelope.hasMore && totalResults > pageEnd) {
9191
throw new Error('Oracle collection hasMore contradicts totalResults')
9292
}
93+
if (totalResults !== undefined && envelope.hasMore && totalResults <= pageEnd) {
94+
throw new Error('Oracle collection hasMore contradicts totalResults')
95+
}
9396
if (options.expectedOffset !== undefined) {
9497
const expectedOffset = nonNegativeInteger(
9598
options.expectedOffset,

0 commit comments

Comments
 (0)