add branch validation to queue

This commit is contained in:
2025-12-22 15:07:11 +01:00
parent 5f4eaaaa20
commit a4205f513d
2 changed files with 131 additions and 41 deletions

View File

@@ -13,6 +13,45 @@ jobs_bp = Blueprint('jobs', __name__, url_prefix='/jobs')
def submit():
return render_template('jobs/submit.html')
@jobs_bp.route('/debug/test-step2')
@login_required
def debug_test_step2():
"""Debug endpoint to test step2 template with mock data"""
if not current_user.is_admin:
return jsonify({'error': 'Admin access required'}), 403
# Mock data similar to what we expect from scenario scan
organized_data = {
"drivers": {
"diag_protocol_stack": ["diag_protocol_stack_init_test"]
},
"application_layer": {
"data_pool": ["data_pool_init_test"],
"actuator_manager": ["actuator_manager_init_test2", "actuator_manager_init_test"],
"event_system": ["event_system_init_test"]
}
}
scenario_map = {
"diag_protocol_stack_init_test": "drivers/diag_protocol_stack/test/diag_protocol_stack_init_test.test_scenario.xml",
"data_pool_init_test": "application_layer/DP_stack/data_pool/test/data_pool_init_test.test_scenario.xml",
"actuator_manager_init_test2": "application_layer/business_stack/actuator_manager/test/actuator_manager_init_test2.test_scenario.xml",
"actuator_manager_init_test": "application_layer/business_stack/actuator_manager/test/actuator_manager_init_test.test_scenario.xml",
"event_system_init_test": "application_layer/business_stack/event_system/test/event_system_init_test.test_scenario.xml"
}
try:
return render_template('jobs/submit_step2.html',
branch_name='test_branch',
organized_data=organized_data,
scenario_map=scenario_map)
except Exception as e:
return jsonify({
'error': str(e),
'type': type(e).__name__,
'template_exists': True
})
@jobs_bp.route('/debug/ssh-test')
@login_required
def debug_ssh_test():
@@ -216,21 +255,46 @@ def submit_step1():
@jobs_bp.route('/submit/step2-validated', methods=['POST'])
@login_required
def submit_step2_validated():
branch_name = request.form.get('branch_name')
organized_data_json = request.form.get('organized_data')
scenario_map_json = request.form.get('scenario_map')
try:
organized_data = json.loads(organized_data_json) if organized_data_json else {}
scenario_map = json.loads(scenario_map_json) if scenario_map_json else {}
except json.JSONDecodeError:
flash('Invalid scenario data', 'error')
return redirect(url_for('jobs.submit'))
branch_name = request.form.get('branch_name')
organized_data_json = request.form.get('organized_data')
scenario_map_json = request.form.get('scenario_map')
print(f"[DEBUG] Step2 - Branch: {branch_name}")
print(f"[DEBUG] Step2 - Organized data length: {len(organized_data_json) if organized_data_json else 0}")
print(f"[DEBUG] Step2 - Scenario map length: {len(scenario_map_json) if scenario_map_json else 0}")
if not branch_name:
print("[ERROR] Step2 - No branch name provided")
flash('Branch name is required', 'error')
return redirect(url_for('jobs.submit'))
try:
organized_data = json.loads(organized_data_json) if organized_data_json else {}
scenario_map = json.loads(scenario_map_json) if scenario_map_json else {}
print(f"[DEBUG] Step2 - Parsed organized_data keys: {list(organized_data.keys())}")
print(f"[DEBUG] Step2 - Parsed scenario_map count: {len(scenario_map)}")
except json.JSONDecodeError as e:
print(f"[ERROR] Step2 - JSON decode error: {e}")
flash('Invalid scenario data', 'error')
return redirect(url_for('jobs.submit'))
print(f"[DEBUG] Step2 - Rendering template with {len(organized_data)} layers")
return render_template('jobs/submit_step2.html',
branch_name=branch_name,
organized_data=organized_data,
scenario_map=scenario_map)
return render_template('jobs/submit_step2.html',
branch_name=branch_name,
organized_data=organized_data,
scenario_map=scenario_map)
except Exception as e:
print(f"[ERROR] Step2 - Unexpected error: {str(e)}")
print(f"[ERROR] Step2 - Error type: {type(e).__name__}")
import traceback
print(f"[ERROR] Step2 - Traceback: {traceback.format_exc()}")
flash(f'Error loading scenario selection: {str(e)}', 'error')
return redirect(url_for('jobs.submit'))
@login_required
def submit_step2():
branch_name = request.form.get('branch_name')