diff --git a/tests/js/workspace-inspection-state.test.js b/tests/js/workspace-inspection-state.test.js index a1bf464..2ea7976 100644 --- a/tests/js/workspace-inspection-state.test.js +++ b/tests/js/workspace-inspection-state.test.js @@ -555,3 +555,16 @@ test('a setting the file does not record is never filled from the legacy parse', assert.equal(record.generation.cfg.status, 'not-recorded'); assert.equal(record.generation.cfg.value, null); }); + +test('a workflow the legacy parser throws on keeps the server result instead of failing the record', t => { + globalThis.ComfyMetadata = require('../../web/js/comfy-metadata.js'); + t.after(() => { delete globalThis.ComfyMetadata; }); + const entry = image(), data = envelope(entry); + // The browser parser throws on a null workflow node (it reads properties of it). + data.metadata.workflow_graph = { status: 'parsed', value: { nodes: [null], links: [] } }; + data.metadata.raw.workflow = '{"nodes":[null],"links":[]}'; + data.metadata.record_formats.workflow = 'reserialized-json'; + const record = contract('toInspectionRecord')(data, entry, extractGenerationFacts); + assert.deepEqual(record.prompts.positive, { status: 'resolved', text: 'exact\npositive', source: 'execution' }); + assert.equal(record.prompts.negative.status, 'ambiguous'); +}); diff --git a/web/js/workspace/inspection-state.mjs b/web/js/workspace/inspection-state.mjs index da553ed..920f1f9 100644 --- a/web/js/workspace/inspection-state.mjs +++ b/web/js/workspace/inspection-state.mjs @@ -176,7 +176,9 @@ function withWorkflowParams(record, parser = comfyMetadata()) { const graph = record.metadata.prompt_graph.status === 'parsed' ? record.metadata.prompt_graph.value : null; const workflow = record.metadata.workflow_graph.status === 'parsed' ? record.metadata.workflow_graph.value : null; if (typeof parser?.extractGenerationParams !== 'function' || (!graph && !workflow)) return; - const params = parser.extractGenerationParams({ prompt: graph, workflow }); + let params; + // The browser parser throws on some malformed graphs; then only the server result shows. + try { params = parser.extractGenerationParams({ prompt: graph, workflow }); } catch { return; } const found = key => typeof params[key] === 'string' || typeof params[key] === 'number' ? String(params[key]) !== '' && params[key] !== parser.PLACEHOLDERS?.[key] : false; const prompts = { ...record.prompts };