mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-10-27 15:17:18 +09:00
33 routes wrapped their body in try/except Exception only to return unexpected_response(e), which records the crash and answers the same body the global 500 handler already does. Every site was directly in a route function, so the handler sees the same exceptions. SAML metadata relied on its wrapper for an unconfigured IdP; that is now a typed 404 instead of a logged crash on a public, probed route.
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""Support bundle API: build and download a scrubbed diagnostic zip.
|
|
|
|
Registration (app/__init__.py):
|
|
from app.api.support_bundle import support_bundle_bp
|
|
app.register_blueprint(support_bundle_bp, url_prefix='/api/v1/support-bundle')
|
|
"""
|
|
import os
|
|
from datetime import datetime
|
|
|
|
from flask import Blueprint, jsonify, send_file
|
|
|
|
from app.middleware.rbac import admin_required
|
|
from app.services import support_bundle_service
|
|
|
|
support_bundle_bp = Blueprint('support_bundle', __name__)
|
|
|
|
|
|
@support_bundle_bp.route('', methods=['POST'])
|
|
@admin_required
|
|
def build_support_bundle():
|
|
"""Build a diagnostic support bundle and return it as a zip download."""
|
|
path = support_bundle_service.build()
|
|
|
|
if not os.path.isfile(path):
|
|
return jsonify({'error': 'Support bundle was not created'}), 500
|
|
|
|
filename = f"serverkit-support-{datetime.utcnow().strftime('%Y-%m-%d')}.zip"
|
|
return send_file(
|
|
path,
|
|
mimetype='application/zip',
|
|
as_attachment=True,
|
|
download_name=filename,
|
|
max_age=0,
|
|
)
|