From 0ab6dfb6e272e040cc31947472d9461059866e8d Mon Sep 17 00:00:00 2001 From: "Will Gibson (Made Tech)" <261894875+willgibson-madetech@users.noreply.github.com> Date: Tue, 5 May 2026 14:03:25 +0100 Subject: [PATCH 1/3] chore: Add logging around wreck materials images (MCABAND-285) --- webapp/api/routes/report/check-your-answers.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/api/routes/report/check-your-answers.js b/webapp/api/routes/report/check-your-answers.js index 3b57dcce..d9e24fed 100644 --- a/webapp/api/routes/report/check-your-answers.js +++ b/webapp/api/routes/report/check-your-answers.js @@ -96,11 +96,14 @@ export default function (app) { for (const prop in sd['property']) { if (sd['property'].hasOwnProperty(prop)) { const innerObj = sd['property'][prop]; + const uploadsPath = '../../../uploads/'; + console.log(`Resolving wreck material file path for ${__dirname} ${uploadsPath} ${innerObj.image}`); const filePath = path.resolve( __dirname, - '../../../uploads/', + uploadsPath, innerObj.image ); + console.log(`Wreck material file path is ${filePath}`); try { const imageData = await fs.promises.readFile(filePath, 'base64'); @@ -117,6 +120,7 @@ export default function (app) { data['wreck-materials'].push(innerObj); } catch (error) { console.error('Error reading file:', error); + console.error('Full file read error object:', JSON.stringify(error)); data['wreck-materials'].push(innerObj); } } From 798ff2d96386d5b70641f7b83c1e18c8b17ddd5b Mon Sep 17 00:00:00 2001 From: "Will Gibson (Made Tech)" <261894875+willgibson-madetech@users.noreply.github.com> Date: Tue, 5 May 2026 14:04:32 +0100 Subject: [PATCH 2/3] Add quotes --- webapp/api/routes/report/check-your-answers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/api/routes/report/check-your-answers.js b/webapp/api/routes/report/check-your-answers.js index d9e24fed..dea0f6b2 100644 --- a/webapp/api/routes/report/check-your-answers.js +++ b/webapp/api/routes/report/check-your-answers.js @@ -97,7 +97,7 @@ export default function (app) { if (sd['property'].hasOwnProperty(prop)) { const innerObj = sd['property'][prop]; const uploadsPath = '../../../uploads/'; - console.log(`Resolving wreck material file path for ${__dirname} ${uploadsPath} ${innerObj.image}`); + console.log(`Resolving wreck material file path for '${__dirname}' '${uploadsPath}' '${innerObj.image}'`); const filePath = path.resolve( __dirname, uploadsPath, From 5b65d0d895f88071beda2fcce177ea01e2e9b6d0 Mon Sep 17 00:00:00 2001 From: "Will Gibson (Made Tech)" <261894875+willgibson-madetech@users.noreply.github.com> Date: Tue, 5 May 2026 14:14:17 +0100 Subject: [PATCH 3/3] Add todo --- webapp/api/routes/report/check-your-answers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/api/routes/report/check-your-answers.js b/webapp/api/routes/report/check-your-answers.js index dea0f6b2..6dbe5b4b 100644 --- a/webapp/api/routes/report/check-your-answers.js +++ b/webapp/api/routes/report/check-your-answers.js @@ -121,6 +121,7 @@ export default function (app) { } catch (error) { console.error('Error reading file:', error); console.error('Full file read error object:', JSON.stringify(error)); + // Todo: If it didn't manage to read the image file, the post to the API will fail. We need to decide how we want to handle this possibility data['wreck-materials'].push(innerObj); } }