From 74440b11b2ca7cacca7a4b9f1489b76d9caae7f3 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:01:47 +0000 Subject: [PATCH] chore: add debug logging to generatePartialSHA Co-Authored-By: shryas.londhe@gmail.com --- packages/helpers/src/sha-utils.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/helpers/src/sha-utils.ts b/packages/helpers/src/sha-utils.ts index bdb30619..0626ccc7 100644 --- a/packages/helpers/src/sha-utils.ts +++ b/packages/helpers/src/sha-utils.ts @@ -53,6 +53,9 @@ export function generatePartialSHA({ const result: number[] = []; let i = 0; + // Debug logging + console.log('Original body:', bodyBuffer.toString()); + while (i < bodyBuffer.length) { // Skip soft line breaks if (i < bodyBuffer.length - 2 && @@ -82,12 +85,19 @@ export function generatePartialSHA({ const decoder = new TextDecoder(); const decodedStr = decoder.decode(new Uint8Array(result)); + // Debug logging + console.log('Decoded body:', decodedStr); + console.log('Looking for selector:', selectorString); + // Find the selector in decoded content const selectorIndex = decodedStr.indexOf(selectorString); if (selectorIndex === -1) { - throw new Error(`SHA precompute selector "${selectorString}" not found in body`); + throw new Error(`SHA precompute selector "${selectorString}" not found in cleaned body`); } + // Debug logging + console.log('Found selector at index:', selectorIndex); + // Map back to original index let originalIndex = 0; let decodedIndex = 0; @@ -111,6 +121,10 @@ export function generatePartialSHA({ } } shaCutoffIndex = originalIndex; + + // Debug logging + console.log('Original cutoff index:', shaCutoffIndex); + console.log('Original content at cutoff:', bodyBuffer.slice(shaCutoffIndex, shaCutoffIndex + 50).toString()); } if (shaCutoffIndex < 0) {