From 6c4ce2678d01f773a29c3820cef0051314342683 Mon Sep 17 00:00:00 2001 From: "Dr. Ernie Prabhakar" Date: Tue, 5 Nov 2024 10:26:38 -0800 Subject: [PATCH] Fix To json errors (#260) Java has brain-dead JSON handling, and I didn't properly try/catch that part... --------- Co-authored-by: Dr. Ernie Prabhakar <19791+drernie@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ .../main/nextflow/quilt/QuiltProduct.groovy | 23 +++++++++++++------ .../nextflow/quilt/jep/QuiltPackage.groovy | 2 +- .../src/resources/META-INF/MANIFEST.MF | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba2d32b7..3fca9e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - Improve handling of dynamically-specified URIs - Rewrite README.md, splitting out developer documentation to README_DEV.md +## [0.8.11] 2024-11-5 UNPUBLISHED + +- Catch *all* toJson errors + ## [0.8.10] 2024-11-4 UNPUBLISHED - Ignore publish to 'home' diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy index a87c4e58..392337e2 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy @@ -207,8 +207,12 @@ ${nextflow} String writeNextflowMetadata(Map map, String suffix) { String filename = "nf-quilt/${suffix}.json" - // log.debug("writeNextflowMetadata[$suffix]: ${filename}") - writeString(QuiltPackage.toJson(map), pkg, filename) + log.debug("writeNextflowMetadata[$suffix]: ${filename}") + try { + writeString(QuiltPackage.toJson(map), pkg, filename) + } catch (Exception e) { + log.error("writeNextflowMetadata.toJson failed: ${e.getMessage()}", map) + } return filename } @@ -227,7 +231,7 @@ ${nextflow} writeNextflowMetadata(params, 'params') params.remove('genomes') params.remove('test_data') - // printMap(params, 'params') + printMap(params, 'params') } Map wf = session.getWorkflowMetadata().toMap() String start = wf['start'] @@ -241,7 +245,7 @@ ${nextflow} wf.remove('complete') wf.remove('workflowStats') wf.remove('commandLine') - // printMap(wf, 'workflow') + printMap(wf, 'workflow') log.info("\npublishing: ${wf['runName']}") } @@ -264,7 +268,7 @@ ${nextflow} log.error("setupReadme failed: ${e.getMessage()}\n{$e}", pkg.meta) } if (text != null && text.length() > 0) { - //log.debug("setupReadme: ${text.length()} bytes") + log.debug("setupReadme: ${text.length()} bytes") writeString(text, pkg, README_FILE) } return text @@ -342,8 +346,13 @@ ${nextflow} } } - String qs_json = JsonOutput.toJson(quilt_summarize) - writeString(qs_json, pkg, SUMMARY_FILE) + try { + String qs_json = JsonOutput.toJson(quilt_summarize) + writeString(qs_json, pkg, SUMMARY_FILE) + } + catch (Exception e) { + log.error("setupSummarize.toJson failed: ${e.getMessage()}\n{$e}", SUMMARY_FILE) + } return quilt_summarize } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy index 537305ac..60ea4f7d 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy @@ -81,7 +81,7 @@ class QuiltPackage { List entries = dict.collect { key, value -> String prefix = JsonOutput.toJson(key) String suffix = "toJson.error: ${value}" - // log.debug("QuiltPackage.toJson: ${prefix} [${suffix.length()}]") + log.debug("QuiltPackage.toJson: ${prefix} [${suffix.length()}]") try { suffix = JsonOutput.toJson(value) } diff --git a/plugins/nf-quilt/src/resources/META-INF/MANIFEST.MF b/plugins/nf-quilt/src/resources/META-INF/MANIFEST.MF index d1ec193e..d7d518e3 100644 --- a/plugins/nf-quilt/src/resources/META-INF/MANIFEST.MF +++ b/plugins/nf-quilt/src/resources/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Plugin-Class: nextflow.quilt.QuiltPlugin Plugin-Id: nf-quilt -Plugin-Version: 0.8.10 +Plugin-Version: 0.8.11 Plugin-Provider: Quilt Data Plugin-Requires: >=22.10.6