Skip to content

Commit cad6ab6

Browse files
author
Tom Brandenburg
committed
fix: resolve template validation failures in CI/CD
- Fix ai-chat-memory-template: connect init_conversation_id node to execution flow - Fix CLI shell script generation: add missing env var warnings as proper shell comments - Prevent stderr pollution in generated shell scripts that caused syntax errors - Update error detection patterns to catch unbound variables and division by zero - Templates now generate syntactically valid shell scripts with proper warning comments
1 parent 2debcc7 commit cad6ab6

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

scripts/run-all-templates.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ for template in templates/basic/*-template.yaml templates/enhanced/*-simple.yaml
4141
echo " ✅ Executed successfully"
4242
success=$((success + 1))
4343
# STRICT ERROR CLASSIFICATION - Zero tolerance for critical failures
44-
elif grep -q "bash:.*unbound variable\|syntax error\|command not found.*get_var\|Failed to resolve template content" "$result_file"; then
44+
elif grep -q "unbound variable\|syntax error\|command not found.*get_var\|Failed to resolve template content\|division by zero" "$result_file"; then
4545
echo " ❌ CRITICAL FAILURE - Shell script error detected"
4646
echo " Critical errors:"
47-
grep "bash:.*unbound variable\|syntax error\|command not found.*get_var\|Failed to resolve template content" "$result_file" | head -3 | sed 's/^/ /'
47+
grep "unbound variable\|syntax error\|command not found.*get_var\|Failed to resolve template content\|division by zero" "$result_file" | head -3 | sed 's/^/ /'
4848
elif grep -q "Missing.*API.*key\|OPENAI_API_KEY.*required\|Telegram chat_id is required\|requires.*API.*key" "$result_file" && \
49-
! grep -q "bash:.*unbound variable\|syntax error\|Failed to resolve template content" "$result_file"; then
49+
! grep -q "unbound variable\|syntax error\|Failed to resolve template content\|division by zero" "$result_file"; then
5050
echo " ⚠️ ACCEPTABLE - Missing environment variables (template functional)"
5151
success=$((success + 1))
5252
elif grep -q "Mock circuit breaker.*operation failed\|Circuit breaker operation failed\|Mock circuit breaker: operation failed" "$result_file" && \
53-
! grep -q "bash:.*unbound variable\|syntax error\|command not found.*get_var\|Failed to resolve template content" "$result_file"; then
53+
! grep -q "unbound variable\|syntax error\|command not found.*get_var\|Failed to resolve template content\|division by zero" "$result_file"; then
5454
echo " ✅ Expected behavior - circuit breaker demonstrating failure handling"
5555
success=$((success + 1))
5656
else

src/cli/index.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,25 @@ async function compileCommand(
109109
console.error('');
110110
}
111111

112-
// Check for missing environment variables and warn user
112+
// Check for missing environment variables and add as comments to script
113113
const missingEnvVars = scanMissingEnvironmentVariables(parseResult.workflow);
114+
let finalScript = generateResult.script;
114115
if (missingEnvVars.length > 0) {
115-
console.error('⚠️ Missing environment variables:');
116-
missingEnvVars.forEach(varName => {
117-
console.error(` → ${varName} (consider setting this before running the script)`);
118-
});
119-
console.error('');
116+
const warnings = [
117+
'# ⚠️ Missing environment variables:',
118+
...missingEnvVars.map(
119+
varName => `# → ${varName} (consider setting this before running the script)`
120+
),
121+
'#',
122+
];
123+
finalScript = warnings.join('\n') + '\n' + finalScript;
120124
}
121125

122126
// Dry-run mode: validate and compile but don't output
123127
if (options.dryRun) {
124128
const nodeCount = parseResult.workflow?.graph?.nodes?.length || 0;
125129
const edgeCount = parseResult.workflow?.graph?.edges?.length || 0;
126-
const scriptLines = generateResult.script.split('\n').length;
130+
const scriptLines = finalScript.split('\n').length;
127131

128132
console.log(`✅ Dry-run successful for ${workflowFile}`);
129133
console.log(` Nodes: ${nodeCount}, Edges: ${edgeCount}`);
@@ -143,10 +147,10 @@ async function compileCommand(
143147

144148
// Output to file or stdout
145149
if (options.output) {
146-
await writeScriptToFile(generateResult.script, options.output);
150+
await writeScriptToFile(finalScript, options.output);
147151
} else {
148152
// Output to stdout (jq-like behavior)
149-
console.log(generateResult.script);
153+
console.log(finalScript);
150154
}
151155
} catch (error) {
152156
handleError(error, 'Compilation');

templates/advanced/ai-workflows/ai-chat-memory-template.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ graph:
360360
361361
edges:
362362
- source: 'start'
363+
target: 'init_conversation_id'
364+
- source: 'init_conversation_id'
363365
target: 'initialize_memory_system'
364366
- source: 'initialize_memory_system'
365367
target: 'load_conversation_history'

0 commit comments

Comments
 (0)