Skip to content

Commit 27e0acf

Browse files
authored
feat: improve stac-validate logs TDE-1385 (#1189)
#### Motivation When a STAC validation fails on a link checksum, it requires some manual research to find which is the parent document that contains this failing link. #### Modification Add the following information in the checksum validation logs: - Add the STAC document path of the parent that contains the link being checked - Add the link rel or "type" ``` json {"level":20,"time":1738618069598,"pid":129823,"hostname":"linz","id":"01JK6VCRF3BXTHK5HT9YZ11MZV","source":"memory://stac/item.json","checksum":"12206fd977db9b2afe87a9ceee48432881299a6aaf83d935fbbe83007660287f9c2e","type":"item","parent":"memory://stac/collection.json","duration":0.16163199999999733,"msg":"Checksum:Validation:Ok"} ``` #### Checklist _If not applicable, provide explanation of why._ - [ ] Tests updated - [ ] Docs updated - [X] Issue linked in Title
1 parent e2d75d7 commit 27e0acf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/commands/stac-validate/stac.validate.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,12 @@ export async function validateStacChecksum(
308308

309309
if (checksum == null) {
310310
if (allowMissing) return true;
311-
logger.error({ source, checksum }, 'Validate:Checksum:Missing');
311+
logger.error({ source, checksum, type: stacObject.rel, parent: path }, 'Validate:Checksum:Missing');
312312
return false;
313313
}
314314

315315
if (!checksum.startsWith(Sha256Prefix)) {
316-
logger.error({ source, checksum }, 'Validate:Checksum:Unknown');
316+
logger.error({ source, checksum, type: stacObject.rel, parent: path }, 'Validate:Checksum:Unknown');
317317
return false;
318318
}
319319
logger.debug({ source, checksum }, 'Validate:Checksum');
@@ -322,10 +322,13 @@ export async function validateStacChecksum(
322322
const duration = performance.now() - startTime;
323323

324324
if (hash !== checksum) {
325-
logger.error({ source, checksum, found: hash, duration }, 'Checksum:Validation:Failed');
325+
logger.error(
326+
{ source, checksum, found: hash, type: stacObject.rel, parent: path, duration },
327+
'Checksum:Validation:Failed',
328+
);
326329
return false;
327330
}
328-
logger.debug({ source, checksum, duration }, 'Checksum:Validation:Ok');
331+
logger.debug({ source, checksum, type: stacObject.rel, parent: path, duration }, 'Checksum:Validation:Ok');
329332
return true;
330333
}
331334

0 commit comments

Comments
 (0)