Skip to content

Commit ee3bde0

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(bitbucket): overfetch small pipeline log tails
1 parent 172ffde commit ee3bde0

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

apps/sim/tools/bitbucket/pipelines.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,19 @@ describe('Bitbucket pipeline step logs', () => {
398398
})
399399
})
400400

401+
it('overfetches a provider-compatible minimum for small log tails', () => {
402+
const params = {
403+
...REPOSITORY_PARAMS,
404+
pipelineUuid: '{pipeline-1}',
405+
stepUuid: '{step-1}',
406+
maxCharacters: 100,
407+
} satisfies BitbucketGetPipelineStepLogParams
408+
409+
expect(bitbucketGetPipelineStepLogTool.request.headers(params)).toMatchObject({
410+
Range: 'bytes=-4096',
411+
})
412+
})
413+
401414
it('trims the partial leading line of a ranged log and reports total bytes', async () => {
402415
const body = 'ise\nFAILED: expected 1 to be 2\n'
403416
const result = await bitbucketGetPipelineStepLogTool.transformResponse!(

apps/sim/tools/bitbucket/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const BITBUCKET_DEFAULT_MAX_CHARACTERS = 100_000
2525
export const BITBUCKET_MAX_CHARACTERS = 500_000
2626
export const BITBUCKET_DEFAULT_LOG_CHARACTERS = 20_000
2727
export const BITBUCKET_MAX_LOG_CHARACTERS = 200_000
28+
export const BITBUCKET_MIN_LOG_RANGE_BYTES = 4_096
2829
export const BITBUCKET_RAW_TRANSFER_MAX_BYTES = 10 * 1024 * 1024
2930

3031
export const BITBUCKET_READ_RETRY: ToolRetryConfig = {
@@ -242,7 +243,10 @@ export function bitbucketHeadRange(maxCharacters: number | undefined): string {
242243
}
243244

244245
export function bitbucketTailRange(maxCharacters: number | undefined): string {
245-
const byteLimit = bitbucketMaxCharacters(maxCharacters, true) * 4
246+
const byteLimit = Math.max(
247+
bitbucketMaxCharacters(maxCharacters, true) * 4,
248+
BITBUCKET_MIN_LOG_RANGE_BYTES
249+
)
246250
return `bytes=-${byteLimit}`
247251
}
248252

0 commit comments

Comments
 (0)