From 3e93dbbc89db7e296537846775fd048be0133fa0 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 9 Apr 2026 20:49:45 +0200 Subject: [PATCH] fix: Placeholder field name mismatch + debug logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root Cause: - PlaceholderPicker used q.id for signal placeholders - Backend template context used question_type - Placeholders never matched → empty values Frontend PlaceholderPicker.jsx: - Changed signal_${q.id} → signal_${q.type} (matches backend) - Added question_${q.type} placeholders (question texts) - New category: "Workflow - Questions" Backend workflow_executor.py: - Added extensive debug logging for template context - Logs all signal_* and question_* keys + values - Helps diagnose template rendering issues Example: - Question configured with type="kalorienbilanz" - Frontend now shows: {{ node_4.signal_kalorienbilanz }} - Frontend now shows: {{ node_4.question_kalorienbilanz }} - Backend creates: template_context['node_4']['signal_kalorienbilanz'] - Should match and render correctly Issue: Signal placeholders show empty values Version: 0.9p (workflow module) Part 3: End Node Template Engine - Field Name Fix Co-Authored-By: Claude Opus 4.6 --- backend/workflow_executor.py | 11 +++++++++++ .../workflow/panels/PlaceholderPicker.jsx | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/backend/workflow_executor.py b/backend/workflow_executor.py index 56d76b6..cdadb4a 100644 --- a/backend/workflow_executor.py +++ b/backend/workflow_executor.py @@ -624,6 +624,17 @@ def execute_end_node( logger.debug(f"End node {node.id}: Built template context for {len(template_context)} nodes") + # DEBUG: Log template context keys for each node + for node_id, node_ctx in template_context.items(): + logger.info(f"End node template context[{node_id}]: {list(node_ctx.keys())}") + # Log signal keys specifically + signal_keys = [k for k in node_ctx.keys() if k.startswith('signal_')] + question_keys = [k for k in node_ctx.keys() if k.startswith('question_')] + if signal_keys: + logger.info(f" Signals: {signal_keys} → values: {[(k, node_ctx[k]) for k in signal_keys]}") + if question_keys: + logger.info(f" Questions: {question_keys} → values: {[(k, node_ctx[k]) for k in question_keys]}") + # Render template try: jinja_template = Template(node.template) diff --git a/frontend/src/components/workflow/panels/PlaceholderPicker.jsx b/frontend/src/components/workflow/panels/PlaceholderPicker.jsx index 1259aaa..1f9b163 100644 --- a/frontend/src/components/workflow/panels/PlaceholderPicker.jsx +++ b/frontend/src/components/workflow/panels/PlaceholderPicker.jsx @@ -372,17 +372,27 @@ function extractWorkflowPlaceholders(nodes) { }) } - // Signals für Analysis Nodes mit Fragen + // Signals und Fragen für Analysis Nodes if (node.type === 'analysis' && node.data.questions && node.data.questions.length > 0) { node.data.questions.forEach((q, qIdx) => { - const questionId = q.id || `q${qIdx + 1}` + const questionType = q.type || `q${qIdx + 1}` const questionText = q.question || `Frage ${qIdx + 1}` + + // Signal-Platzhalter (Antwort) placeholders.push({ - placeholder: `{{ ${nodeId}.signal_${questionId} }}`, + placeholder: `{{ ${nodeId}.signal_${questionType} }}`, description: `${nodeLabel} - Signal: ${questionText.substring(0, 50)}${questionText.length > 50 ? '...' : ''}`, icon: '📊', category: 'Workflow - Signals' }) + + // Frage-Text-Platzhalter + placeholders.push({ + placeholder: `{{ ${nodeId}.question_${questionType} }}`, + description: `${nodeLabel} - Frage-Text: ${questionText.substring(0, 50)}${questionText.length > 50 ? '...' : ''}`, + icon: '❓', + category: 'Workflow - Questions' + }) }) } })