ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
Read route bodies through json_object()
Juan Denis55d8fb1e4451
diff --git a/backend/app/api/_request.py b/backend/app/api/_request.pyindex 138b82c3..2fde1bfe 100644--- a/backend/app/api/_request.py+++ b/backend/app/api/_request.py@@ -4,14 +4,18 @@ from flask import requestfrom app.exceptions import ValidationError-def json_object():+def json_object(optional=False):"""The request body as a dict, or a 400.``request.get_json()`` hands back whatever JSON was sent, so a body of- ``null`` or ``[]`` reached ``data.get(...)`` and crashed the route into a- 500. Empty and non-JSON bodies are already rejected by Flask.+ ``null``, ``[]`` or a bare string reached ``data.get(...)`` and crashed+ the route into a 500. Flask already rejects a missing or non-JSON body+ (415/400); with ``optional=True`` that case is an empty dict instead,+ for action endpoints whose body is all optional settings."""- data = request.get_json()+ data = request.get_json(silent=True) if optional else request.get_json()+ if data is None and optional:+ return {}if not isinstance(data, dict):raise ValidationError('Request body must be a JSON object',code='validation.body_not_object')diff --git a/backend/app/api/admin.py b/backend/app/api/admin.pyindex 26193299..8514147f 100644--- a/backend/app/api/admin.py+++ b/backend/app/api/admin.py@@ -37,7 +37,7 @@ def list_users():@admin_requireddef create_user():"""Create a new user."""- data = request.get_json()+ data = json_object()current_user_id = get_jwt_identity()if not data:@@ -105,7 +105,7 @@ def get_user(user_id):@admin_requireddef update_user(user_id):"""Update a user."""- data = request.get_json()+ data = json_object()current_user_id = get_jwt_identity()user = User.query.get(user_id)@@ -305,7 +305,7 @@ def get_settings():@admin_requireddef update_settings():"""Update system settings."""- data = request.get_json()+ data = json_object()current_user_id = get_jwt_identity()if not data:@@ -392,7 +392,7 @@ def get_domain_detection():@admin_requireddef set_canonical_domain():"""Persist the canonical panel domain and HTTPS flag."""- data = request.get_json() or {}+ data = json_object()domain = (data.get('domain') or '').strip().lower()https_enabled = bool(data.get('https_enabled', False))current_user_id = get_jwt_identity()@@ -442,7 +442,7 @@ def sites_https_setup():"""Create the wildcard DNS record + issue the wildcard cert for a base domain(the default base when ``base`` is omitted)."""from app.services.sites_https_service import SitesHttpsService- data = request.get_json() or {}+ data = json_object()result = SitesHttpsService.setup(data.get('provider_id'), email=data.get('email'),base=data.get('base') or data.get('domain'))return jsonify(result), 200 if result.get('success') else 400@@ -453,7 +453,7 @@ def sites_https_setup():def sites_base_domain_add():"""Register a base domain managed sites can publish under."""from app.services.site_base_domain_service import SiteBaseDomainService- data = request.get_json() or {}+ data = json_object()result = SiteBaseDomainService.add(data.get('domain'),dns_provider_config_id=data.get('provider_id') or data.get('dns_provider_config_id'),@@ -486,7 +486,7 @@ def sites_base_domain_set_default(domain):def sites_base_domain_update(domain):"""Update a base domain's DNS mode (wildcard | per-site)."""from app.services.site_base_domain_service import SiteBaseDomainService- data = request.get_json() or {}+ data = json_object()result = SiteBaseDomainService.update(domain, dns_mode=data.get('dns_mode'))return jsonify(result), 200 if result.get('success') else 404@@ -542,7 +542,7 @@ def get_user_permissions(user_id):@admin_requireddef update_user_permissions(user_id):"""Update a user's custom permissions."""- data = request.get_json()+ data = json_object()current_user_id = get_jwt_identity()if not data or 'permissions' not in data:diff --git a/backend/app/api/advanced_ssl.py b/backend/app/api/advanced_ssl.pyindex 8596f6aa..e8045663 100644--- a/backend/app/api/advanced_ssl.py+++ b/backend/app/api/advanced_ssl.py@@ -4,6 +4,7 @@ from app.services.advanced_ssl_service import AdvancedSSLServicefrom app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import get_current_user+from app.api._request import json_objectadvanced_ssl_bp = Blueprint('advanced_ssl', __name__)@@ -21,7 +22,7 @@ def issue_wildcard():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()domain = data.get('domain')provider = data.get('dns_provider')creds = data.get('credentials', {})@@ -46,7 +47,7 @@ def issue_san():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()domains = data.get('domains', [])if not domains:return jsonify({'error': 'domains list required'}), 400@@ -66,7 +67,7 @@ def upload_cert():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()domain = data.get('domain')cert = data.get('certificate')key = data.get('private_key')diff --git a/backend/app/api/agent_plugins.py b/backend/app/api/agent_plugins.pyindex 435631f6..c0cd231b 100644--- a/backend/app/api/agent_plugins.py+++ b/backend/app/api/agent_plugins.py@@ -4,6 +4,7 @@ from app.services.agent_plugin_service import AgentPluginServicefrom app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import get_current_user+from app.api._request import json_objectagent_plugins_bp = Blueprint('agent_plugins', __name__)@@ -112,7 +113,7 @@ def install_plugin(plugin_id):if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()server_id = data.get('server_id')if not server_id:return jsonify({'error': 'server_id required'}), 400@@ -140,7 +141,7 @@ def bulk_install_plugin(plugin_id):if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()server_ids = data.get('server_ids', [])if not server_ids:return jsonify({'error': 'server_ids required'}), 400@@ -211,7 +212,7 @@ def update_install_config(install_id):if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json()+ data = json_object()if not data or 'config' not in data:return jsonify({'error': 'config required'}), 400diff --git a/backend/app/api/agent_poll.py b/backend/app/api/agent_poll.pyindex 218cb373..e63f27bd 100644--- a/backend/app/api/agent_poll.py+++ b/backend/app/api/agent_poll.py@@ -20,6 +20,7 @@ import loggingfrom flask import Blueprint, jsonify, requestfrom app.services.agent_registry import agent_registry+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -86,7 +87,7 @@ def poll():if not agent:return jsonify({'error': 'invalid session'}), 401- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)metrics = body.get('metrics') or {}sysinfo = body.get('system_info')caps = body.get('capabilities')diff --git a/backend/app/api/ai.py b/backend/app/api/ai.pyindex 5e29eabc..0b38ed4d 100644--- a/backend/app/api/ai.py+++ b/backend/app/api/ai.py@@ -44,6 +44,7 @@ from app.services.ai_tool_registry import ai_tool_registryfrom app.error_reporting import unexpected_responsefrom app.exceptions import ApplicationError, DependencyUnavailableError, ValidationErrorfrom app.services import ai_management, ai_usage, ai_runtime+from app.api._request import json_objectlogger = logging.getLogger(__name__)ai_bp = Blueprint('ai', __name__)@@ -275,7 +276,7 @@ def update_settings():@admin_requireddef test_settings():from app.services.settings_service import SettingsService- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)provider = (data.get('provider') or SettingsService.get('ai_provider', '')).strip()model = (data.get('model') or SettingsService.get('ai_model', '')).strip()endpoint = data.get('endpoint')@@ -389,7 +390,7 @@ def list_conversations():@jwt_required()def create_conversation():user = get_current_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)mode = data.get('mode') or AiConversation.MODE_ASSISTANTtry:row = _load_or_create(None, user, mode, data.get('connection_id'), data.get('model'),@@ -418,7 +419,7 @@ def rename_conversation(conversation_id):row = _owned_conversation(conversation_id, user)if row is None:return jsonify({'error': 'Conversation not found'}), 404- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if 'title' in data:row.title = (data['title'] or '').strip()[:256] or row.titledb.session.commit()@@ -454,7 +455,7 @@ def chat():user = get_current_user()if not ai_service.is_configured():return jsonify({'error': 'AI assistant is not configured'}), 503- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)invalid = _validate_chat_data(data)if invalid:raise ValidationError(invalid)@@ -541,7 +542,7 @@ def chat_stream():user = get_current_user()if not ai_service.is_configured():return jsonify({'error': 'AI assistant is not configured'}), 503- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)invalid = _validate_chat_data(data)if invalid:raise ValidationError(invalid)@@ -732,7 +733,7 @@ def chat_stream():@jwt_required()def chat_confirm():user = get_current_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)conversation_id = data.get('conversation_id')token = data.get('action_token')decision = 'approve' if data.get('decision') == 'approve' else 'deny'@@ -755,7 +756,7 @@ def chat_confirm():@jwt_required()def chat_cancel():user = get_current_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)conversation_id = data.get('conversation_id')if not conversation_id:return jsonify({'error': 'conversation_id is required'}), 400diff --git a/backend/app/api/api_keys.py b/backend/app/api/api_keys.pyindex 74a00d35..a9975b52 100644--- a/backend/app/api/api_keys.py+++ b/backend/app/api/api_keys.py@@ -1,6 +1,6 @@"""API Key management endpoints."""from datetime import datetime-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.middleware.rbac import get_current_userfrom app.middleware.api_scope_middleware import SCOPES, require_scope@@ -8,6 +8,7 @@ from app.services.api_key_service import ApiKeyServicefrom app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.exceptions import not_found+from app.api._request import json_objectapi_keys_bp = Blueprint('api_keys', __name__)@@ -40,7 +41,7 @@ def create_key():if not user or not user.is_developer:return jsonify({'error': 'Developer access required'}), 403- data = request.get_json() or {}+ data = json_object()name = data.get('name')if not name:return jsonify({'error': 'Name is required'}), 400@@ -100,7 +101,7 @@ def update_key(key_id):if not user or not user.is_developer:return jsonify({'error': 'Developer access required'}), 403- data = request.get_json() or {}+ data = json_object()api_key = ApiKeyService.update_key(key_id=key_id,user_id=user.id,diff --git a/backend/app/api/app_attachments.py b/backend/app/api/app_attachments.pyindex 78a7e6fe..b814bb4a 100644--- a/backend/app/api/app_attachments.py+++ b/backend/app/api/app_attachments.py@@ -19,6 +19,7 @@ from app.models.app_attachment import AppAttachmentfrom app.services.app_attachment_service import (FAILURE_MODES, AppAttachmentService, AttachmentError)from app.services.resource_grant_service import ResourceGrantService+from app.api._request import json_objectapp_attachments_bp = Blueprint('app_attachments', __name__)@@ -58,7 +59,7 @@ def attach_service(app_id, kind):app = AppAttachmentService.live_app(app_id)if app is None or not ResourceGrantService.can_edit_app(user, app):raise not_found('service')- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)service_app_id = data.get('service_app_id')if not isinstance(service_app_id, int) or isinstance(service_app_id, bool):raise ValidationError("'service_app_id' is required")@@ -114,7 +115,7 @@ def set_pooler(app_id):raise not_found('service')if not pooler_service.is_postgres_engine(app):raise ValidationError('Connection pooling is for an installed PostgreSQL')- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if not isinstance(data.get('enabled'), bool):raise ValidationError("'enabled' must be true or false")result = pooler_service.set_enabled(app, data['enabled'])@@ -144,7 +145,7 @@ def set_immutable_assets(app_id):app = AppAttachmentService.live_app(app_id)if app is None or not ResourceGrantService.can_edit_app(get_current_user(), app):raise not_found('service')- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if not isinstance(data.get('enabled'), bool):raise ValidationError("'enabled' must be true or false")return jsonify(SiteDomainService.set_immutable_assets(app, data['enabled']))diff --git a/backend/app/api/app_slots.py b/backend/app/api/app_slots.pyindex bf94487a..01dbc0a7 100644--- a/backend/app/api/app_slots.py+++ b/backend/app/api/app_slots.py@@ -17,12 +17,13 @@release ran. Destroys later writes; anexplicit second step after a rollback."""-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom app.exceptions import ValidationErrorfrom app.middleware.rbac import developer_required, get_current_user, viewer_requiredfrom app.services.slot_deploy_service import SlotDeployServicefrom app.api._access import require_app+from app.api._request import json_objectapp_slots_bp = Blueprint('app_slots', __name__)@@ -38,7 +39,7 @@ def get_slots(app_id):@developer_requireddef set_slots(app_id):app = require_app(app_id, write=True, conceal=True)- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)enabled = data.get('enabled')if not isinstance(enabled, bool):raise ValidationError("'enabled' must be true or false")@@ -62,7 +63,7 @@ def switch_back(app_id):@developer_requireddef restore_db(app_id):app = require_app(app_id, write=True, conceal=True)- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)deployment_id = data.get('deployment_id')if not isinstance(deployment_id, int) or isinstance(deployment_id, bool):raise ValidationError("'deployment_id' is required")@@ -86,7 +87,7 @@ def compose_split_preview(app_id):@developer_requireddef compose_split_apply(app_id):app = require_app(app_id, write=True, conceal=True)- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if data.get('confirm') is not True:raise ValidationError("Moving the stateful services stops the service once; send ""{'confirm': true} after reading the preview")diff --git a/backend/app/api/app_volumes.py b/backend/app/api/app_volumes.pyindex bee7a595..f8d85053 100644--- a/backend/app/api/app_volumes.py+++ b/backend/app/api/app_volumes.py@@ -9,6 +9,7 @@ from flask_jwt_extended import jwt_requiredfrom app.services.volume_service import VolumeService, VolumeErrorfrom app.api._access import require_app+from app.api._request import json_objectapp_volumes_bp = Blueprint('app_volumes', __name__)@@ -25,7 +26,7 @@ def list_volumes(app_id):@jwt_required()def attach_volume(app_id):app = require_app(app_id, write=True)- data = request.get_json() or {}+ data = json_object()try:volume = VolumeService.create(app,@@ -62,7 +63,7 @@ def convert_bind_mount(app_id):into it. (Deviates from the plan's ``/<vid>/convert`` — a convert creates anew volume, so there is no prior vid.)"""app = require_app(app_id, write=True)- data = request.get_json() or {}+ data = json_object()host_path = data.get('host_path')mount_path = data.get('mount_path')if not host_path or not mount_path:diff --git a/backend/app/api/apps.py b/backend/app/api/apps.pyindex c068d228..320d132f 100644--- a/backend/app/api/apps.py+++ b/backend/app/api/apps.py@@ -49,6 +49,7 @@ from app.exceptions import (PermissionDeniedError, ValidationError, field_required, not_found, permission_denied,)from app.api._access import require_app+from app.api._request import json_objectapps_bp = Blueprint('apps', __name__)@@ -144,7 +145,7 @@ def link_apps(app_id):if not _can_edit_app(user, app):raise permission_denied()- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -331,7 +332,7 @@ def update_environment(app_id):if not _can_edit_app(user, app):raise permission_denied()- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -481,7 +482,7 @@ def move_apps_to_project():from app.models.environment import Environmentuser = get_current_user()- data = request.get_json() or {}+ data = json_object()raw_ids = data.get('app_ids')if not isinstance(raw_ids, list) or not raw_ids:@@ -677,7 +678,7 @@ def grant_app_access(app_id):raise not_found('service')if not user.is_admin and app.user_id != user.id:raise permission_denied()- data = request.get_json() or {}+ data = json_object()grantee_id = data.get('user_id')if not grantee_id:raise field_required('user_id')@@ -715,7 +716,7 @@ def create_app_from_repository():"""Create a new application by cloning a Git repository."""user = require_admin_user()- data = request.get_json() or {}+ data = json_object()name = _service_slug(data.get('name'))repo_url = (data.get('repo_url') or '').strip()source_connection_id = data.get('source_connection_id')@@ -923,7 +924,7 @@ _HOST_BINDING_FIELDS = ('root_path', 'compose_file', 'systemd_unit', 'managed_bydef create_app():user = get_current_user()current_user_id = user.id- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -997,7 +998,7 @@ def create_manual_app():"""Register an app that already exists on the server (manual/local)."""user = require_admin_user()- data = request.get_json() or {}+ data = json_object()name = _service_slug(data.get('name'))app_type = (data.get('app_type') or 'docker').strip().lower()root_path = (data.get('root_path') or '').strip()@@ -1274,7 +1275,7 @@ def rollback_app_version(app_id):if app.source != 'upload':return jsonify({'error': 'Rollback is only available for services deployed by upload'}), 400- data = request.get_json() or {}+ data = json_object()target = data.get('version')if target is None:raise field_required('version')@@ -1324,7 +1325,7 @@ def update_app(app_id):if not _can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()# Validate before anything is assigned, so a bad setting leaves the app# untouched rather than half-updated in the session.@@ -1551,7 +1552,7 @@ def update_sleep_policy(app_id):raise not_found('service')if not _can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()policy = ContainerSleepService.set_policy(app_id, enabled=data.get('enabled'), idle_timeout_minutes=data.get('idle_timeout_minutes'))return jsonify(policy.to_dict())@@ -1673,7 +1674,7 @@ def update_app_resources(app_id):if not _can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()try:if 'cpu_limit' in data:app.cpu_limit = DockerService.validate_cpu_limit(data['cpu_limit'])@@ -1730,7 +1731,7 @@ def set_micro_cache(app_id):if not _can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()if 'enabled' not in data:return jsonify({'error': "'enabled' is required"}), 400@@ -2285,7 +2286,7 @@ def delete_app_backup(app_id, run_id):# --------------------------------------------------------------------------- #-# WordPress reachable through the generic application surface (§7 unification).+# WordPress reachable through the generic application surface.# A WordPress site is a 1:1 extension of an Application (WordPressSite.# application_id); the WordPressSite record — not app_type — is the source of# truth (see wordpress.py:_is_wp_app). These additive routes expose the WP@@ -2352,7 +2353,7 @@ def create_app_db_snapshot(app_id):WordPressEnvService = wordpress_env_service()except WordPressExtensionMissingError as e:return jsonify({'error': str(e)}), 503- data = request.get_json() or {}+ data = json_object()result = DatabaseSyncService.create_snapshot(db_name=site.db_name,name=data.get('name', f'{app.name}_{site.id}'),diff --git a/backend/app/api/auth.py b/backend/app/api/auth.pyindex 972a631a..74043392 100644--- a/backend/app/api/auth.py+++ b/backend/app/api/auth.py@@ -22,6 +22,7 @@ from app.utils.i18n import normalize_languagefrom app.exceptions import (AuthenticationError, ConflictError, PermissionDeniedError, ValidationError, not_found,)+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -75,7 +76,7 @@ def get_setup_status():@auth_bp.route('/register', methods=['POST'])@limiter.limit("3 per minute")def register():- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -195,7 +196,7 @@ def complete_onboarding():"""Complete the onboarding wizard and mark setup as done."""user = require_admin_user()- data = request.get_json() or {}+ data = json_object()use_cases = data.get('use_cases', [])# Validate use_cases@@ -262,7 +263,7 @@ def login():'error': 'Too many failed login attempts. Try again later.'}), 429, {'Retry-After': str(retry_after)}- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -346,7 +347,7 @@ def login():def create_login_link():"""Mint a single-use login URL. The raw token is returned exactly once."""current = require_admin_user()- data = request.get_json() or {}+ data = json_object()target_id = data.get('user_id') or current.idtarget = User.query.get(target_id)@@ -422,7 +423,7 @@ def redeem_login_link():'error': 'Too many failed attempts. Try again later.'}), 429, {'Retry-After': str(retry_after)}- data = request.get_json() or {}+ data = json_object()token = data.get('token')user, reason = login_link_service.redeem(token, client_ip)@@ -599,7 +600,7 @@ def update_current_user():if not user:raise not_found('user')- data = request.get_json() or {}+ data = json_object()if 'password' in data:import time@@ -693,7 +694,7 @@ def passkey_register():user = User.query.get(user_id)if not user:raise not_found('user')- data = request.get_json() or {}+ data = json_object()credential = data.get('credential')device_name = data.get('device_name', 'Passkey')if not credential:@@ -725,7 +726,7 @@ def passkey_delete(passkey_id):def passkey_auth_options():"""Begin WebAuthn authentication (public, challenge only)."""from app.services.passkey_service import PasskeyService- data = request.get_json() or {}+ data = json_object()user_id = data.get('user_id')user = User.query.get(user_id) if user_id else Noneoptions = PasskeyService.begin_authentication(user)@@ -738,7 +739,7 @@ def passkey_authenticate():"""Verify a WebAuthn assertion and issue JWT tokens."""from app.services.passkey_service import PasskeyServicefrom app.services import sso_service- data = request.get_json() or {}+ data = json_object()credential = data.get('credential')user_id = data.get('user_id')if not credential:diff --git a/backend/app/api/backups.py b/backend/app/api/backups.pyindex f90bd341..f19097a9 100644--- a/backend/app/api/backups.py+++ b/backend/app/api/backups.py@@ -8,6 +8,7 @@ from app.services.backup_policy_service import BackupPolicyService, BackupPolicyfrom app.services.storage_provider_service import StorageProviderServicefrom app import db, pathsfrom app.exceptions import field_required, not_found+from app.api._request import json_objectbackups_bp = Blueprint('backups', __name__)@@ -77,7 +78,7 @@ def get_stats():@admin_requireddef list_policies():"""Global list of policy-driven backup schedules across every target type- (§8 unification). Optional filters: ?target_type=, ?enabled=true|false.+. Optional filters: ?target_type=, ?enabled=true|false.Replaces the legacy filesystem schedule list (/backups/schedules) for theunified Backups page — one queryable view of every BackupPolicy.@@ -113,7 +114,7 @@ def list_policies():@backups_bp.route('/runs', methods=['GET'])@admin_requireddef list_runs():- """Global, queryable list of backup runs across every policy (§8).+ """Global, queryable list of backup runs across every policy.Optional filters: ?target_type=, ?status=, ?policy_id=, ?limit= (<=500).Each run is augmented with its policy's target_type/target_id so the unified@@ -149,7 +150,7 @@ def list_runs():# --------------------------------------------------------------------------- #-# Generic policy-driven backup CRUD by (target_type, target_id) (§8).+# Generic policy-driven backup CRUD by (target_type, target_id).# One surface for every BackupPolicy target — apps, WordPress sites, databases,# file path-lists, servers. The per-resource mounts# (/apps/:id/backup-policy, /wordpress/sites/:id/backup-policy) remain as@@ -174,7 +175,7 @@ def get_target_policy(target_type, target_id):def update_target_policy(target_type, target_id):"""Update a policy. Body may include target_subtype/target_meta (needed todescribe database/files targets) plus the usual schedule/retention fields."""- data = request.get_json() or {}+ data = json_object()subtype = data.pop('target_subtype', None)meta = data.pop('target_meta', None)try:@@ -282,7 +283,7 @@ def get_cost_rates():def update_cost_rates():"""Update storage-cost rates. Accepts {rates:{local,s3,b2}} or the flat dict."""from app.services.backup_cost_service import BackupCostService- data = request.get_json() or {}+ data = json_object()rates = BackupCostService.save_rates(data.get('rates') if 'rates' in data else data)return jsonify({'success': True, 'rates': rates}), 200@@ -334,7 +335,7 @@ def cost_summary():@admin_requireddef backup_application():"""Backup an application."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -361,7 +362,7 @@ def backup_application():@admin_requireddef backup_database():"""Backup a database."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -386,7 +387,7 @@ def backup_database():@admin_requireddef backup_files():"""Backup specific files and directories."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -407,7 +408,7 @@ def backup_files():@admin_requireddef restore_application():"""Restore an application from backup."""- data = request.get_json()+ data = json_object()if not data or 'backup_path' not in data:raise field_required('backup_path')@@ -424,7 +425,7 @@ def restore_application():@admin_requireddef restore_database():"""Restore a database from backup."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -462,7 +463,7 @@ def delete_backup(backup_path):@admin_requireddef cleanup_backups():"""Clean up old backups."""- data = request.get_json() or {}+ data = json_object()retention_days = data.get('retention_days')result = BackupService.cleanup_old_backups(retention_days)@@ -484,7 +485,7 @@ def list_schedules():@admin_requireddef add_schedule():"""Add a backup schedule."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -575,7 +576,7 @@ def test_storage_connection():@admin_requireddef upload_to_remote():"""Upload a local backup to remote storage."""- data = request.get_json()+ data = json_object()if not data or 'backup_path' not in data:raise field_required('backup_path')@@ -598,7 +599,7 @@ def upload_to_remote():@admin_requireddef verify_remote_backup():"""Verify a backup exists and matches on remote storage."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -629,7 +630,7 @@ def list_remote_backups():@admin_requireddef download_from_remote():"""Download a backup from remote storage to local."""- data = request.get_json()+ data = json_object()if not data or 'remote_key' not in data:raise field_required('remote_key')diff --git a/backend/app/api/bandwidth.py b/backend/app/api/bandwidth.pyindex 1c61ee42..d7cd40ae 100644--- a/backend/app/api/bandwidth.py+++ b/backend/app/api/bandwidth.py@@ -14,6 +14,7 @@ from ..models import Applicationfrom ..services.bandwidth_service import BandwidthServicefrom ..services.request_metrics_service import RequestMetricsServicefrom ..services.resource_grant_service import ResourceGrantService+from app.api._request import json_objectbandwidth_bp = Blueprint('bandwidth', __name__)@@ -66,7 +67,7 @@ def get_app_request_metrics(app_id):def run_aggregate():"""Run the daily aggregation now (optionally for a specific day)."""try:- payload = request.get_json(silent=True) or {}+ payload = json_object(optional=True)result = BandwidthService.aggregate(day=payload.get('day'))return jsonify(result)except ValueError:diff --git a/backend/app/api/buildpacks.py b/backend/app/api/buildpacks.pyindex f9c74b37..2eec6ad8 100644--- a/backend/app/api/buildpacks.py+++ b/backend/app/api/buildpacks.py@@ -16,13 +16,14 @@ import osimport shutilimport tempfile-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services.buildpack_service import BuildpackServicefrom app.services.git_service import GitServicefrom app.services.source_connection_service import SourceConnectionServicefrom app.middleware.rbac import developer_required, get_current_user+from app.api._request import json_objectbuildpacks_bp = Blueprint('buildpacks', __name__)@@ -46,7 +47,7 @@ def detect():If ``path`` is supplied it is used directly (no clone). Otherwise the repo iscloned shallowly to a temp workspace, inspected, and the workspace removed."""- data = request.get_json() or {}+ data = json_object()# Through the one identity door: @developer_required admits API-key# callers, for whom reading the JWT directly raises.caller = get_current_user()@@ -125,7 +126,7 @@ def generate():Body: {plan, overrides?, name?}"""- data = request.get_json() or {}+ data = json_object()plan = data.get('plan')if not isinstance(plan, dict):return jsonify({'error': 'plan (object) is required'}), 400diff --git a/backend/app/api/builds.py b/backend/app/api/builds.pyindex 0bb41bbc..337d9ac6 100644--- a/backend/app/api/builds.py+++ b/backend/app/api/builds.py@@ -18,6 +18,7 @@ from app.services.build_service import BuildServicefrom app.services.deployment_service import DeploymentServicefrom app.services.resource_grant_service import ResourceGrantServicefrom app.exceptions import not_found, permission_denied+from app.api._request import json_objectbuilds_bp = Blueprint('builds', __name__)@@ -53,7 +54,7 @@ def configure_build(app_id):if not app:raise not_found('service')- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -140,7 +141,7 @@ def trigger_build(app_id):if not ResourceGrantService.can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()no_cache = data.get('no_cache', False)result = BuildService.build(app_id, no_cache=no_cache)@@ -216,7 +217,7 @@ def deploy_app(app_id):if not ResourceGrantService.can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()no_cache = data.get('no_cache', False)version_tag = data.get('version_tag')wait = request.args.get('wait', 'false').lower() == 'true'@@ -331,7 +332,7 @@ def rollback(app_id):if not ResourceGrantService.can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()target_version = data.get('version') # Optional - if not provided, rolls back to previousresult = DeploymentService.rollback(diff --git a/backend/app/api/connections.py b/backend/app/api/connections.pyindex bf6518fb..312d2038 100644--- a/backend/app/api/connections.py+++ b/backend/app/api/connections.py@@ -20,6 +20,7 @@ from app.services.connection_provider_sdk import (from app.services import connection_providers # noqa: F401from app.services.container_registry_service import ContainerRegistryServicefrom app.services.workspace_service import WorkspaceService+from app.api._request import json_objectconnections_bp = Blueprint('connections', __name__)@@ -168,7 +169,7 @@ def list_registries():@connections_bp.route('/registries', methods=['POST'])@admin_requireddef create_registry():- data = request.get_json() or {}+ data = json_object()name = (data.get('name') or '').strip()if not name:return jsonify({'error': 'name is required'}), 400@@ -191,7 +192,7 @@ def update_registry(registry_id):registry = ContainerRegistryService.get(registry_id)if not registry:return jsonify({'error': 'Registry not found'}), 404- data = request.get_json() or {}+ data = json_object()registry = ContainerRegistryService.update(registry,name=data.get('name'),diff --git a/backend/app/api/cron.py b/backend/app/api/cron.pyindex ae45c5a0..63298af2 100644--- a/backend/app/api/cron.py+++ b/backend/app/api/cron.py@@ -230,7 +230,7 @@ def jobs_for_app(app_id):def toggle_tracking(job_id):"""Enable/disable run tracking for a job (rewrites its crontab line with theserverkit-cron-run shim; disabling restores the bare command)."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)enabled = bool(data.get('enabled', True))options = {}if 'alert_on_failure' in data:@@ -271,7 +271,7 @@ def ingest_run():if remote not in ('127.0.0.1', '::1', 'localhost'):return jsonify({'error': 'Ingest is restricted to localhost'}), 403- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)job_id = data.get('job_id')if not job_id:return jsonify({'error': 'job_id is required'}), 400@@ -334,7 +334,7 @@ def preview_schedule():existing cron read gate rather than the admin write gate — the Backups andserver-detail embedders shouldn't need admin to preview a schedule."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)schedule = data.get('schedule', '')result = CronService.preview_schedule(schedule)return jsonify(result)diff --git a/backend/app/api/dashboards.py b/backend/app/api/dashboards.pyindex 6e57b647..07fd70c9 100644--- a/backend/app/api/dashboards.py+++ b/backend/app/api/dashboards.py@@ -15,11 +15,12 @@ would be a broken dashboard the user cannot fix without an API call."""import logging-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.services import dashboard_servicefrom app.services.dashboard_service import GRID_COLS, MAX_WIDGETS_PER_BOARD+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -138,7 +139,7 @@ def create_board():"""Add a board for this user. ``widgets`` is optional — a new tab usuallystarts empty and gets filled from the widget library."""user_id = get_jwt_identity()- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)name, err = _validate_name(body.get('name'))if err:@@ -169,7 +170,7 @@ def update_board(board_id):if not board:return jsonify({'error': 'Board not found'}), 404- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)name = icon = position = widgets = Noneif body.get('name') is not None:diff --git a/backend/app/api/database_engines.py b/backend/app/api/database_engines.pyindex 20953dfe..7cb6ef45 100644--- a/backend/app/api/database_engines.py+++ b/backend/app/api/database_engines.py@@ -29,6 +29,7 @@ from app.services import database_engine_service as enginesfrom app.services.deployment_job_service import DeploymentJobServicefrom app.services.template_service import TemplateServicefrom app.api._access import require_app+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -70,7 +71,7 @@ def install_database_engine():so the caller navigates to the deploy console exactly as it would for anyother template install."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)plan = engines.plan_install(template_id=data.get('template_id'),@@ -155,7 +156,7 @@ def install_engine_extension(app_id):gets "your image does not carry this, install X instead" rather than a raw``could not open extension control file``."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)result = extensions.install_extension(app_id,extension_id=data.get('extension_id') or data.get('id'),diff --git a/backend/app/api/databases.py b/backend/app/api/databases.pyindex 14296f68..a17761e3 100644--- a/backend/app/api/databases.py+++ b/backend/app/api/databases.py@@ -16,6 +16,7 @@ from app.services.managed_database_service import ManagedDatabaseServicefrom app.middleware.rbac import admin_required, get_current_user, require_admin_userfrom app.services.resource_grant_service import ResourceGrantServicefrom app.exceptions import field_required, not_found, permission_denied+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -70,7 +71,7 @@ def list_mysql_databases():@admin_requireddef create_mysql_database():"""Create a MySQL database."""- data = request.get_json()+ data = json_object()if not data or 'name' not in data:raise field_required('name')@@ -111,7 +112,7 @@ def create_mysql_database():@admin_requireddef drop_mysql_database(name):"""Drop a MySQL database."""- data = request.get_json() or {}+ data = json_object()result = DatabaseService.mysql_drop_database(name, data.get('root_password'))return jsonify(result), 200 if result['success'] else 400@@ -132,7 +133,7 @@ def get_mysql_tables(name):@admin_requireddef backup_mysql_database(name):"""Backup a MySQL database."""- data = request.get_json() or {}+ data = json_object()result = DatabaseService.mysql_backup(name, root_password=data.get('root_password'))return jsonify(result), 200 if result['success'] else 400@@ -141,7 +142,7 @@ def backup_mysql_database(name):@admin_requireddef restore_mysql_database(name):"""Restore a MySQL database from backup."""- data = request.get_json()+ data = json_object()if not data or 'backup_path' not in data:raise field_required('backup_path')@@ -172,7 +173,7 @@ def list_mysql_users():@admin_requireddef create_mysql_user():"""Create a MySQL user."""- data = request.get_json()+ data = json_object()if not data or 'username' not in data:raise field_required('username')@@ -206,7 +207,7 @@ def create_mysql_user():@admin_requireddef drop_mysql_user(username):"""Drop a MySQL user."""- data = request.get_json() or {}+ data = json_object()host = data.get('host', 'localhost')result = DatabaseService.mysql_drop_user(username, host, data.get('root_password'))return jsonify(result), 200 if result['success'] else 400@@ -229,7 +230,7 @@ def get_mysql_user_privileges(username):@admin_requireddef grant_mysql_privileges(username):"""Grant privileges to a MySQL user."""- data = request.get_json()+ data = json_object()if not data or 'database' not in data:raise field_required('database')@@ -248,7 +249,7 @@ def grant_mysql_privileges(username):@admin_requireddef revoke_mysql_privileges(username):"""Revoke privileges from a MySQL user."""- data = request.get_json()+ data = json_object()if not data or 'database' not in data:raise field_required('database')@@ -277,7 +278,7 @@ def list_pg_databases():@admin_requireddef create_pg_database():"""Create a PostgreSQL database."""- data = request.get_json()+ data = json_object()if not data or 'name' not in data:raise field_required('name')@@ -330,7 +331,7 @@ def backup_pg_database(name):@admin_requireddef restore_pg_database(name):"""Restore a PostgreSQL database from backup."""- data = request.get_json()+ data = json_object()if not data or 'backup_path' not in data:raise field_required('backup_path')@@ -353,7 +354,7 @@ def list_pg_users():@admin_requireddef create_pg_user():"""Create a PostgreSQL user."""- data = request.get_json()+ data = json_object()if not data or 'username' not in data:raise field_required('username')@@ -388,7 +389,7 @@ def drop_pg_user(username):@admin_requireddef grant_pg_privileges(username):"""Grant privileges to a PostgreSQL user."""- data = request.get_json()+ data = json_object()if not data or 'database' not in data:raise field_required('database')@@ -405,7 +406,7 @@ def grant_pg_privileges(username):@admin_requireddef revoke_pg_privileges(username):"""Revoke privileges from a PostgreSQL user."""- data = request.get_json()+ data = json_object()if not data or 'database' not in data:raise field_required('database')@@ -450,7 +451,7 @@ def execute_mysql_query(name):Security: Readonly mode is enforced by default. Admin role required to disable."""- data = request.get_json()+ data = json_object()if not data or 'query' not in data:raise field_required('query')@@ -486,7 +487,7 @@ def execute_pg_query(name):Security: Readonly mode is enforced by default. Admin role required to disable."""- data = request.get_json()+ data = json_object()if not data or 'query' not in data:raise field_required('query')@@ -521,7 +522,7 @@ def execute_sqlite_query():Security: Readonly mode is enforced by default. Admin role required to disable."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data or 'query' not in data:return jsonify({'error': 'path and query are required'}), 400@@ -723,7 +724,7 @@ def execute_docker_query(container, database):Security: Readonly mode is enforced by default. Admin role required to disable."""- data = request.get_json()+ data = json_object()if not data or 'query' not in data:raise field_required('query')@@ -774,7 +775,7 @@ def list_managed_databases():@admin_requireddef create_managed_database():"""Provision a new database (mysql|postgresql) AND track it as managed."""- data = request.get_json() or {}+ data = json_object()engine = (data.get('engine') or '').strip().lower()name = data.get('name')if not name:@@ -818,7 +819,7 @@ def create_managed_database():@admin_requireddef adopt_managed_database():"""Track a live-discovered database that isn't tracked yet."""- data = request.get_json() or {}+ data = json_object()engine = (data.get('engine') or '').strip().lower()name = data.get('name')if not name or engine not in ('mysql', 'postgresql', 'mongodb'):@@ -887,7 +888,7 @@ def protect_managed_database(managed_id):managed = ManagedDatabaseService.get(managed_id)if not managed:raise not_found('database')- data = request.get_json() or {}+ data = json_object()policy = ManagedDatabaseService.protect(managed, fields=data.get('policy'))return jsonify({'policy': policy.to_dict()}), 201@@ -949,7 +950,7 @@ def list_docker_db_processes(container):@admin_requireddef kill_docker_db_process(container, pid):"""Kill/terminate a process inside a Docker database container (admin only)."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)target = {'engine': data.get('type') or request.args.get('type', 'mysql'),'container': container,diff --git a/backend/app/api/db_tuner.py b/backend/app/api/db_tuner.pyindex cb299489..1dbfbbe8 100644--- a/backend/app/api/db_tuner.py+++ b/backend/app/api/db_tuner.py@@ -20,6 +20,7 @@ from flask import Blueprint, request, jsonifyfrom app.middleware.rbac import admin_requiredfrom app.services.db_config_tuner_service import DbConfigTunerService+from app.api._request import json_objectdb_tuner_bp = Blueprint('db_tuner', __name__)@@ -72,7 +73,7 @@ def inspect_target(target):@admin_requireddef apply_target(target):"""Apply an explicit operator-chosen settings dict (restarts the engine)."""- data = request.get_json() or {}+ data = json_object()if not data.get('settings'):return jsonify({'error': 'settings is required'}), 400resolved, err = _build_target(target, data)diff --git a/backend/app/api/ddns.py b/backend/app/api/ddns.pyindex 926cd0db..ed36809b 100644--- a/backend/app/api/ddns.py+++ b/backend/app/api/ddns.py@@ -2,6 +2,7 @@ from flask import Blueprint, request, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services.ddns_service import DdnsServicefrom app.middleware.rbac import get_current_user+from app.api._request import json_objectddns_bp = Blueprint('ddns', __name__)@@ -68,7 +69,7 @@ def update():"""Called by a router or cron when its public IP changes. There is no JWThere — the per-host token is the credential. The IP can be passed explicitly(?ip=) or inferred from the request source address."""- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)token = request.args.get('token') or request.headers.get('X-DDNS-Token') or body.get('token')if not token:return jsonify({'error': 'token required'}), 401diff --git a/backend/app/api/deploy.py b/backend/app/api/deploy.pyindex dcf3fc58..8b22f10d 100644--- a/backend/app/api/deploy.py+++ b/backend/app/api/deploy.py@@ -11,6 +11,7 @@ from app.models import User, Applicationfrom app.services.git_service import GitServicefrom app.services.resource_grant_service import ResourceGrantServicefrom app.exceptions import not_found, permission_denied+from app.api._request import json_objectdeploy_bp = Blueprint('deploy', __name__)@@ -47,7 +48,7 @@ def configure_deployment(app_id):if not app:raise not_found('service')- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -89,7 +90,7 @@ def trigger_deploy(app_id):if not ResourceGrantService.can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()result = GitService.deploy(app_id, force=data.get('force', False))return jsonify(result), 200 if result['success'] else 400@@ -109,7 +110,7 @@ def pull_changes(app_id):if not ResourceGrantService.can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()result = GitService.pull_changes(app.root_path, data.get('branch'))return jsonify(result), 200 if result['success'] else 400@@ -180,7 +181,7 @@ def get_deployment_history():@admin_requireddef clone_repository():"""Clone a Git repository to a new location."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -229,7 +230,7 @@ def get_branches(app_id):@developer_requireddef get_branches_from_url():"""Get list of branches from a repository URL (before cloning)."""- data = request.get_json()+ data = json_object()if not data or 'repo_url' not in data:return jsonify({'error': 'repo_url is required'}), 400diff --git a/backend/app/api/deployment_jobs.py b/backend/app/api/deployment_jobs.pyindex 4358af12..98ffa813 100644--- a/backend/app/api/deployment_jobs.py+++ b/backend/app/api/deployment_jobs.py@@ -13,6 +13,7 @@ from app.models.deployment_job import DeploymentJob, DeploymentJobLogfrom app.services.deployment_job_service import DeploymentJobServicefrom app.services.resource_grant_service import ResourceGrantServicefrom app.exceptions import not_found, permission_denied+from app.api._request import json_objectdeployment_jobs_bp = Blueprint('deployment_jobs', __name__)@@ -78,7 +79,7 @@ def simulate_deployment():from flask_jwt_extended import get_jwt_identityfrom app.services.demo_deploy_service import DemoDeployService- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)wait = request.args.get('wait', 'false').lower() == 'true'result = DemoDeployService.create(scenario=data.get('scenario') or '',diff --git a/backend/app/api/dns_cutover.py b/backend/app/api/dns_cutover.pyindex 5a8baf68..7d64cad7 100644--- a/backend/app/api/dns_cutover.py+++ b/backend/app/api/dns_cutover.py@@ -14,6 +14,7 @@ from flask_jwt_extended import jwt_requiredfrom app.services.dns_cutover_service import DnsCutoverService, DnsCutoverErrorfrom app.middleware.rbac import require_admin_userfrom app.exceptions import not_found+from app.api._request import json_objectdns_cutover_bp = Blueprint('dns_cutover', __name__)@@ -30,7 +31,7 @@ def _cutover_error(exc):@dns_cutover_bp.route('/ttl-guidance', methods=['POST'])@jwt_required()def ttl_guidance():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)return jsonify(DnsCutoverService.ttl_guidance(data.get('records') or []))@@ -38,7 +39,7 @@ def ttl_guidance():@jwt_required()def create_snapshot():require_admin_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)try:snapshot = DnsCutoverService.create_snapshot(domain=data.get('domain'),@@ -71,7 +72,7 @@ def get_snapshot(snapshot_id):@jwt_required()def cutover():require_admin_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)snapshot_id = data.get('snapshot_id')if not snapshot_id:return jsonify({'error': 'snapshot_id is required — a cutover needs a '@@ -92,7 +93,7 @@ def cutover():@dns_cutover_bp.route('/verify', methods=['POST'])@jwt_required()def verify():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)try:result = DnsCutoverService.verify(domain=data.get('domain'),diff --git a/backend/app/api/dns_providers.py b/backend/app/api/dns_providers.pyindex cdaf56c8..1e61a52a 100644--- a/backend/app/api/dns_providers.py+++ b/backend/app/api/dns_providers.py@@ -6,10 +6,11 @@ still be able to connect a DNS provider. They keep the historical/api/v1/email/dns-providers paths (the routes originally lived in the emailAPI before the extraction) so existing frontends keep working."""-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom app.middleware.rbac import admin_required, viewer_requiredfrom app.services.dns_provider_service import DNSProviderService+from app.api._request import json_objectdns_providers_bp = Blueprint('dns_providers', __name__)@@ -26,7 +27,7 @@ def list_dns_providers():@admin_requireddef add_dns_provider():"""Add a DNS provider."""- data = request.get_json()+ data = json_object()if not data or not data.get('name') or not data.get('provider') or not data.get('api_key'):return jsonify({'success': False, 'error': 'Name, provider, and api_key are required'}), 400result = DNSProviderService.add_provider(diff --git a/backend/app/api/dns_zones.py b/backend/app/api/dns_zones.pyindex 4653db84..75d4e5a0 100644--- a/backend/app/api/dns_zones.py+++ b/backend/app/api/dns_zones.py@@ -2,6 +2,7 @@ from flask import Blueprint, request, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services.dns_zone_service import DNSZoneServicefrom app.middleware.rbac import get_current_user+from app.api._request import json_objectdns_zones_bp = Blueprint('dns_zones', __name__)@@ -30,7 +31,7 @@ def adopt_zone():user = get_current_user()if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()try:zone = DNSZoneService.adopt_zone(data.get('domain'), data.get('dns_provider_config_id'))@@ -153,7 +154,7 @@ def apply_preset(zone_id):user = get_current_user()if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()preset_key = data.get('preset')variables = data.get('variables', {})try:@@ -233,7 +234,7 @@ def import_zone(zone_id):user = get_current_user()if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()content = data.get('zone_file', '')try:records = DNSZoneService.import_zone(zone_id, content)diff --git a/backend/app/api/docker.py b/backend/app/api/docker.pyindex 807094a4..86fcc648 100644--- a/backend/app/api/docker.py+++ b/backend/app/api/docker.py@@ -5,6 +5,7 @@ from app.services.docker_service import DockerServicefrom app.middleware.rbac import admin_requiredfrom app import db, pathsfrom app.error_reporting import unexpected_response+from app.api._request import json_objectdocker_bp = Blueprint('docker', __name__)@@ -65,7 +66,7 @@ def get_container(container_id):@admin_requireddef create_container():"""Create a new container."""- data = request.get_json()+ data = json_object()if not data or 'image' not in data:return jsonify({'error': 'image is required'}), 400@@ -88,7 +89,7 @@ def create_container():@admin_requireddef run_container():"""Run a new container (create and start)."""- data = request.get_json()+ data = json_object()if not data or 'image' not in data:return jsonify({'error': 'image is required'}), 400@@ -136,7 +137,7 @@ def stop_container(container_id):blocked = _reject_if_protected(container_id)if blocked:return blocked- data = request.get_json() or {}+ data = json_object()timeout = data.get('timeout', 10)result = DockerService.stop_container(container_id, timeout)return jsonify(result), 200 if result['success'] else 400@@ -149,7 +150,7 @@ def restart_container(container_id):blocked = _reject_if_protected(container_id)if blocked:return blocked- data = request.get_json() or {}+ data = json_object()timeout = data.get('timeout', 10)result = DockerService.restart_container(container_id, timeout)return jsonify(result), 200 if result['success'] else 400@@ -163,7 +164,7 @@ def remove_container(container_id):if blocked:return blocked- data = request.get_json() or {}+ data = json_object()force = data.get('force', False)volumes = data.get('volumes', False)result = DockerService.remove_container(container_id, force, volumes)@@ -187,7 +188,7 @@ def get_container_logs(container_id):@jwt_required()def get_containers_stats():"""Get resource stats for multiple containers."""- data = request.get_json() or {}+ data = json_object()container_ids = data.get('ids') or data.get('container_ids') or []if not isinstance(container_ids, list):@@ -211,7 +212,7 @@ def get_container_stats(container_id):@admin_requireddef exec_container(container_id):"""Execute a command in a container."""- data = request.get_json()+ data = json_object()if not data or 'command' not in data:return jsonify({'error': 'command is required'}), 400@@ -234,7 +235,7 @@ def list_images():@admin_requireddef pull_image():"""Pull an image from registry."""- data = request.get_json()+ data = json_object()if not data or 'image' not in data:return jsonify({'error': 'image is required'}), 400@@ -250,7 +251,7 @@ def pull_image():@admin_requireddef remove_image(image_id):"""Remove an image."""- data = request.get_json() or {}+ data = json_object()force = data.get('force', False)result = DockerService.remove_image(image_id, force)return jsonify(result), 200 if result['success'] else 400@@ -260,7 +261,7 @@ def remove_image(image_id):@admin_requireddef build_image():"""Build an image from Dockerfile."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data or 'tag' not in data:return jsonify({'error': 'path and tag are required'}), 400@@ -278,7 +279,7 @@ def build_image():@admin_requireddef tag_image():"""Tag an image."""- data = request.get_json()+ data = json_object()if not data or 'source' not in data or 'target' not in data:return jsonify({'error': 'source and target are required'}), 400@@ -301,7 +302,7 @@ def list_networks():@admin_requireddef create_network():"""Create a network."""- data = request.get_json()+ data = json_object()if not data or 'name' not in data:return jsonify({'error': 'name is required'}), 400@@ -335,7 +336,7 @@ def list_volumes():@admin_requireddef create_volume():"""Create a volume."""- data = request.get_json()+ data = json_object()if not data or 'name' not in data:return jsonify({'error': 'name is required'}), 400@@ -351,7 +352,7 @@ def create_volume():@admin_requireddef remove_volume(volume_name):"""Remove a volume."""- data = request.get_json() or {}+ data = json_object()force = data.get('force', False)result = DockerService.remove_volume(volume_name, force)return jsonify(result), 200 if result['success'] else 400@@ -371,7 +372,7 @@ def compose_list():@admin_requireddef compose_up():"""Start Docker Compose services."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -388,7 +389,7 @@ def compose_up():@admin_requireddef compose_down():"""Stop Docker Compose services."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -405,7 +406,7 @@ def compose_down():@admin_requireddef compose_ps():"""List Docker Compose services."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -418,7 +419,7 @@ def compose_ps():@admin_requireddef compose_logs():"""Get Docker Compose logs."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -435,7 +436,7 @@ def compose_logs():@admin_requireddef compose_restart():"""Restart Docker Compose services."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -463,7 +464,7 @@ def docker_cleanup():- Images in use"""- data = request.get_json() or {}+ data = json_object()include_volumes = data.get('volumes', False)results = {@@ -623,7 +624,7 @@ def cleanup_all_apps():@admin_requireddef compose_pull():"""Pull Docker Compose images."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -636,7 +637,7 @@ def compose_pull():@admin_requireddef compose_validate():"""Validate a Docker Compose file."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -649,7 +650,7 @@ def compose_validate():@admin_requireddef compose_config():"""Get parsed Docker Compose configuration."""- data = request.get_json()+ data = json_object()if not data or 'path' not in data:return jsonify({'error': 'path is required'}), 400@@ -664,7 +665,7 @@ def compose_config():@admin_requireddef prune_system():"""Remove unused Docker resources."""- data = request.get_json() or {}+ data = json_object()result = DockerService.prune_system(data.get('all', False),data.get('volumes', False)@@ -678,7 +679,7 @@ def prune_system():@admin_requireddef create_docker_app():"""Create a Docker-based application."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400diff --git a/backend/app/api/doctor.py b/backend/app/api/doctor.pyindex 5915bdd1..0859453a 100644--- a/backend/app/api/doctor.py+++ b/backend/app/api/doctor.py@@ -17,6 +17,7 @@ from flask import Blueprint, jsonify, requestfrom ..middleware.rbac import admin_requiredfrom ..services.doctor_service import DOCTOR_REPAIR_JOB_KIND, DoctorServicefrom ..services.drift_service import DRIFT_JOB_KIND, DriftService+from app.api._request import json_objectdoctor_bp = Blueprint('doctor', __name__)@@ -45,7 +46,7 @@ def run_drift_check():@admin_requireddef repair_drift(check_type, resource_id):"""Repair one drifted resource. Explicit confirmation required."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if data.get('confirm') is not True:return jsonify({'error': 'Confirmation required: pass {"confirm": true}.'}), 400rid = int(resource_id) if resource_id.isdigit() else resource_id@@ -83,7 +84,7 @@ def repair_items():Synchronous remains the default for existing CLI callers. The web shellasks for ``wait=false`` and follows the returned job in Operations."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)items = data.get('items')if not isinstance(items, list) or not items:return jsonify({'error': "Body must carry a non-empty 'items' list."}), 400diff --git a/backend/app/api/domains.py b/backend/app/api/domains.pyindex e22bc2f5..c6f141bd 100644--- a/backend/app/api/domains.py+++ b/backend/app/api/domains.py@@ -147,7 +147,7 @@ def get_domain(domain_id):def create_domain():current_user_id = get_jwt_identity()user = User.query.get(current_user_id)- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -279,7 +279,7 @@ def give_subdomain():publish under a specific registered base domain."""current_user_id = get_jwt_identity()user = User.query.get(current_user_id)- data = request.get_json() or {}+ data = json_object()app = (Application.query_active().filter_by(id=data.get('application_id')).first()if data.get('application_id') else None)if not app:@@ -387,7 +387,7 @@ def enable_ssl(domain_id):if not ResourceGrantService.can_edit_app(user, app):raise permission_denied()- data = request.get_json() or {}+ data = json_object()# An address on the request wins; otherwise the panel-wide ACME contact,# so the modal stops asking for the same address on every certificate.email = get_acme_contact(data.get('email'))diff --git a/backend/app/api/env_vars.py b/backend/app/api/env_vars.pyindex c0c3d101..555f6cbe 100644--- a/backend/app/api/env_vars.py+++ b/backend/app/api/env_vars.py@@ -14,6 +14,7 @@ from app.services.env_service import EnvServicefrom app.services.resource_grant_service import ResourceGrantServicefrom app.api._access import require_appfrom app.middleware.rbac import get_current_user+from app.api._request import json_objectenv_vars_bp = Blueprint('env_vars', __name__)@@ -44,7 +45,7 @@ def create_env_var(app_id):current_user_id = get_jwt_identity()app = require_app(app_id, write=True)- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -97,7 +98,7 @@ def update_env_var(app_id, key):current_user_id = get_jwt_identity()app = require_app(app_id, write=True)- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -150,7 +151,7 @@ def bulk_set_env_vars(app_id):current_user_id = get_jwt_identity()app = require_app(app_id, write=True)- data = request.get_json()+ data = json_object()if not data or 'env_vars' not in data:return jsonify({'error': 'env_vars object is required'}), 400@@ -172,7 +173,7 @@ def import_env_file(app_id):current_user_id = get_jwt_identity()app = require_app(app_id, write=True)- data = request.get_json()+ data = json_object()if not data or 'content' not in data:return jsonify({'error': 'content is required'}), 400diff --git a/backend/app/api/environments.py b/backend/app/api/environments.pyindex 61d25c66..f3b10dd8 100644--- a/backend/app/api/environments.py+++ b/backend/app/api/environments.py@@ -3,7 +3,7 @@Environments are children of a project; access is derived from the parentproject's workspace, mirroring projects.py."""-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services.project_service import ProjectService@@ -11,6 +11,7 @@ from app.services.workspace_service import WorkspaceServicefrom app.middleware.rbac import get_current_userfrom app.exceptions import permission_deniedfrom app.api._access import visible_workspace_ids+from app.api._request import json_objectenvironments_bp = Blueprint('environments', __name__)@@ -34,7 +35,7 @@ def _project_for_write(user, project_id):def create_environment():"""Create an environment under a project. Body: {project_id, name, is_default?}."""user = get_current_user()- data = request.get_json() or {}+ data = json_object()project_id = data.get('project_id')if not project_id:return jsonify({'error': 'project_id is required'}), 400@@ -67,7 +68,7 @@ def update_environment(environment_id):if err:return err- data = request.get_json() or {}+ data = json_object()updated = ProjectService.update_environment(environment_id, name=data.get('name'), is_default=data.get('is_default'))return jsonify({'message': 'Environment updated', 'environment': updated.to_dict(include_counts=True)}), 200@@ -97,7 +98,7 @@ def delete_environment(environment_id):def reorder_environments():"""Reorder a project's environments. Body: {project_id, ordered_ids:[...]}"""user = get_current_user()- data = request.get_json() or {}+ data = json_object()project_id = data.get('project_id')ordered_ids = data.get('ordered_ids')if not project_id:diff --git a/backend/app/api/error_logs.py b/backend/app/api/error_logs.pyindex 8bfb5c1e..94a742b5 100644--- a/backend/app/api/error_logs.py+++ b/backend/app/api/error_logs.py@@ -8,6 +8,7 @@ from flask_jwt_extended import get_jwt_identity, verify_jwt_in_requestfrom app.api._query import PageQueryfrom app.middleware.rbac import admin_requiredfrom app.services import error_log_service+from app.api._request import json_objecterror_logs_bp = Blueprint('error_logs', __name__)@@ -79,7 +80,7 @@ def get_error_log(error_id):@admin_requireddef resolve_error_log(error_id):"""Set the resolved flag: body {"resolved": true|false}."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if not isinstance(data.get('resolved'), bool):return jsonify({'error': 'resolved (boolean) is required'}), 400entry = error_log_service.set_resolved(error_id, data['resolved'])diff --git a/backend/app/api/files.py b/backend/app/api/files.pyindex 476428ff..894b2455 100644--- a/backend/app/api/files.py+++ b/backend/app/api/files.py@@ -6,6 +6,7 @@ from app.exceptions import NotFoundError, PermissionDeniedError, ValidationErrorfrom ..middleware.rbac import permission_requiredfrom ..services.file_service import FileServicefrom ..services.storage_provider_service import StorageProviderService+from app.api._request import json_objectimport osimport tempfile@@ -61,7 +62,7 @@ def read_file():@permission_required('files', 'write')def write_file():"""Write content to a file."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -85,7 +86,7 @@ def write_file():@permission_required('files', 'write')def create_file():"""Create a new file."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -105,7 +106,7 @@ def create_file():@permission_required('files', 'write')def create_directory():"""Create a new directory."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -138,7 +139,7 @@ def delete_path():@permission_required('files', 'write')def rename_path():"""Rename a file or directory."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -158,7 +159,7 @@ def rename_path():@permission_required('files', 'write')def copy_path():"""Copy a file or directory."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -178,7 +179,7 @@ def copy_path():@permission_required('files', 'write')def move_path():"""Move a file or directory."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -198,7 +199,7 @@ def move_path():@permission_required('files', 'write')def change_permissions():"""Change file/directory permissions."""- data = request.get_json()+ data = json_object()if not data:raise ValidationError('Request body is required')@@ -387,7 +388,7 @@ def s3_read():@permission_required('files', 'write')def s3_write():"""Write (create or overwrite) an object from text content."""- data = request.get_json() or {}+ data = json_object()path = data.get('path')content = data.get('content')if not path:diff --git a/backend/app/api/firewall.py b/backend/app/api/firewall.pyindex f4b1d969..81c74078 100644--- a/backend/app/api/firewall.py+++ b/backend/app/api/firewall.py@@ -5,6 +5,7 @@ from flask import Blueprint, request, jsonifyfrom ..middleware.rbac import admin_required, viewer_requiredfrom ..services.firewall_service import FirewallServicefrom ..services.metadata_guard_service import MetadataGuardService, SETTING_KEY+from app.api._request import json_objectfirewall_bp = Blueprint('firewall', __name__)@@ -40,7 +41,7 @@ def enable_firewall():so this is the only thing standing between a click and a locked-out box.Resend with force=true to override."""- data = request.get_json() or {}+ data = json_object()firewall = data.get('firewall')force = bool(data.get('force'))@@ -58,7 +59,7 @@ def enable_firewall():@admin_requireddef disable_firewall():"""Disable the firewall."""- data = request.get_json() or {}+ data = json_object()firewall = data.get('firewall')result = FirewallService.disable(firewall)@@ -84,7 +85,7 @@ def get_rules():@admin_requireddef add_rule():"""Add a firewall rule."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -107,7 +108,7 @@ def add_rule():@viewer_requireddef rule_removal_preflight():"""Would removing this rule cut off SSH? Lets the UI warn before the click."""- data = request.get_json() or {}+ data = json_object()rule_type = data.get('type')kwargs = {k: v for k, v in data.items() if k not in ('type', 'force')}return jsonify(FirewallService.check_ssh_rule_removal(rule_type, **kwargs)), 200@@ -122,7 +123,7 @@ def remove_rule():that is currently enforcing — deleting it would close the caller's ownsession. Resend with force=true to override."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -147,7 +148,7 @@ def remove_rule():@admin_requireddef block_ip():"""Quick block an IP address."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -177,7 +178,7 @@ def block_ip():@admin_requireddef unblock_ip():"""Unblock an IP address."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -210,7 +211,7 @@ def get_blocked_ips():@admin_requireddef allow_port():"""Allow a port through the firewall."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -233,7 +234,7 @@ def allow_port():@admin_requireddef deny_port():"""Remove a port from the firewall."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -272,7 +273,7 @@ def get_zones():@admin_requireddef set_default_zone():"""Set default firewalld zone."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'success': False, 'error': 'Request body required'}), 400@@ -301,7 +302,7 @@ def get_metadata_guard():@admin_requireddef set_metadata_guard():"""Enable or disable the cloud metadata egress guard."""- data = request.get_json()+ data = json_object()if not data or 'enabled' not in data:return jsonify({'error': "Request body with 'enabled' required"}), 400@@ -323,7 +324,7 @@ def set_metadata_guard():@admin_requireddef install_firewall():"""Install a firewall (ufw or firewalld)."""- data = request.get_json() or {}+ data = json_object()firewall = data.get('firewall', 'ufw')result = FirewallService.install_firewall(firewall)diff --git a/backend/app/api/fleet_doctor.py b/backend/app/api/fleet_doctor.pyindex c2b9399a..6aa3dee0 100644--- a/backend/app/api/fleet_doctor.py+++ b/backend/app/api/fleet_doctor.py@@ -19,11 +19,12 @@ owns the allowlist, the capability gate and the audit trail (rule 6) — thislayer only authenticates, shapes the batch, and reports refusals as resultsrather than errors."""-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom ..middleware.rbac import admin_required, get_current_userfrom ..services.fleet_doctor_service import FLEET_DOCTOR_JOB_KIND, FleetDoctorServicefrom ..services.fleet_repair_service import FleetRepairService+from app.api._request import json_objectfleet_doctor_bp = Blueprint('fleet_doctor', __name__)@@ -64,7 +65,7 @@ def repair_fleet_items():as a per-item ``success: false`` result — the request still succeeds, whichis what keeps one offline server from failing the whole batch."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)items = data.get('items')if not isinstance(items, list) or not items:return jsonify({'error': "Body must carry a non-empty 'items' list."}), 400diff --git a/backend/app/api/git.py b/backend/app/api/git.pyindex 225f255d..5795208b 100644--- a/backend/app/api/git.py+++ b/backend/app/api/git.py@@ -18,6 +18,7 @@ from ..models import Application, GitWebhookfrom ..services.webhook_service import WebhookServicefrom ..services.git_deploy_service import GitDeployServicefrom app.exceptions import not_found, permission_denied+from app.api._request import json_objectgit_bp = Blueprint('git', __name__)@@ -64,7 +65,7 @@ def list_webhooks():@admin_requireddef create_webhook():"""Create a new webhook."""- data = request.get_json() or {}+ data = json_object()result = WebhookService.create_webhook(name=data.get('name'),@@ -236,7 +237,7 @@ def get_deployment(deployment_id):@admin_requireddef manual_deploy(app_id):"""Trigger a manual deployment for an application."""- data = request.get_json() or {}+ data = json_object()branch = data.get('branch')result = GitDeployService.manual_deploy(app_id, branch=branch)@@ -250,7 +251,7 @@ def manual_deploy(app_id):@admin_requireddef rollback_deployment(app_id):"""Rollback to a previous deployment version."""- data = request.get_json() or {}+ data = json_object()target_version = data.get('targetVersion')result = GitDeployService.rollback(app_id, target_version=target_version)diff --git a/backend/app/api/htaccess_tools.py b/backend/app/api/htaccess_tools.pyindex 3485c4ea..dcd1a8d9 100644--- a/backend/app/api/htaccess_tools.py+++ b/backend/app/api/htaccess_tools.py@@ -7,10 +7,11 @@ Kept out of apps.py on purpose (separate ownership); intended registration:which exposes POST /api/v1/apps/htaccess-convert."""-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services.htaccess_converter import MAX_INPUT_BYTES, convert+from app.api._request import json_objecthtaccess_tools_bp = Blueprint('htaccess_tools', __name__)@@ -23,7 +24,7 @@ def htaccess_convert():Pure text transform (no server state touched), so any authenticateduser may call it. Body: {'htaccess': '<text>'}."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)text = data.get('htaccess')if not isinstance(text, str) or not text.strip():return jsonify({'error': 'htaccess text is required'}), 400diff --git a/backend/app/api/invitations.py b/backend/app/api/invitations.pyindex b3dad98f..93aa8f84 100644--- a/backend/app/api/invitations.py+++ b/backend/app/api/invitations.py@@ -5,6 +5,7 @@ from app.models import AuditLogfrom app.middleware.rbac import admin_requiredfrom app.services.invitation_service import InvitationServicefrom app.services.audit_service import AuditService+from app.api._request import json_objectinvitations_bp = Blueprint('invitations', __name__)@@ -24,7 +25,7 @@ def list_invitations():@admin_requireddef create_invitation():"""Create a new invitation."""- data = request.get_json()+ data = json_object()current_user_id = get_jwt_identity()if not data:diff --git a/backend/app/api/jobs.py b/backend/app/api/jobs.pyindex 07dc5e6b..1a8c2437 100644--- a/backend/app/api/jobs.py+++ b/backend/app/api/jobs.py@@ -7,6 +7,7 @@ from app.jobs import registryfrom app.jobs.models import Jobfrom app.jobs.service import JobService, ScheduledJobServicefrom app.middleware.rbac import require_admin_user+from app.api._request import json_objectjobs_bp = Blueprint('jobs', __name__)@@ -87,7 +88,7 @@ def run_scheduled(scheduled_id):@jwt_required()def toggle_scheduled(scheduled_id):require_admin_user()- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)scheduled = ScheduledJobService.set_enabled(scheduled_id, bool(body.get('enabled', True)))if not scheduled:return jsonify({'error': 'Scheduled job not found'}), 404diff --git a/backend/app/api/linked_panel.py b/backend/app/api/linked_panel.pyindex 0d6f06b2..efa85728 100644--- a/backend/app/api/linked_panel.py+++ b/backend/app/api/linked_panel.py@@ -1,9 +1,10 @@"""Linked-panel API — manage this panel's link to a master ServerKit panel."""-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.middleware.rbac import developer_requiredfrom app.services.linked_panel_service import LinkedPanelService+from app.api._request import json_objectlinked_panel_bp = Blueprint('linked_panel', __name__)@@ -25,7 +26,7 @@ def link():The registration token comes from the master's Servers page (Add Server/ regenerate-token) — the same token the Go agent consumes."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)result = LinkedPanelService.link(master_url=data.get('master_url'),registration_token=data.get('registration_token'),diff --git a/backend/app/api/logs.py b/backend/app/api/logs.pyindex c0da88ed..f9625d44 100644--- a/backend/app/api/logs.py+++ b/backend/app/api/logs.py@@ -1,6 +1,7 @@from flask import Blueprint, request, jsonifyfrom app.middleware.rbac import admin_requiredfrom app.services.log_service import LogService+from app.api._request import json_objectlogs_bp = Blueprint('logs', __name__)@@ -71,7 +72,7 @@ def get_journal_logs():@admin_requireddef clear_log():"""Clear/truncate a log file."""- data = request.get_json()+ data = json_object()filepath = data.get('path') if data else Noneif not filepath:diff --git a/backend/app/api/managed_db_users.py b/backend/app/api/managed_db_users.pyindex 6294d627..d65ad8fb 100644--- a/backend/app/api/managed_db_users.py+++ b/backend/app/api/managed_db_users.py@@ -14,6 +14,7 @@ from app.middleware.rbac import admin_required, developer_requiredfrom app.services.managed_database_service import ManagedDatabaseServicefrom app.services.managed_db_user_service import ManagedDbUserServicefrom app.exceptions import not_found+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -46,7 +47,7 @@ def create_managed_db_user(managed_id):managed, err = _get_managed_or_404(managed_id)if err:return err- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)result = ManagedDbUserService.create_user(managed,username=data.get('username'),diff --git a/backend/app/api/manifests.py b/backend/app/api/manifests.pyindex 81c798af..cd3c0090 100644--- a/backend/app/api/manifests.py+++ b/backend/app/api/manifests.py@@ -18,6 +18,7 @@ from app.services.manifest_apply_service import ManifestApplyServicefrom app.services.manifest_persistence_service import ManifestPersistenceServicefrom app.middleware.rbac import require_admin_userfrom app.exceptions import not_found+from app.api._request import json_objectmanifests_bp = Blueprint('manifests', __name__)@@ -73,7 +74,7 @@ def validate_manifest():"""POST /api/v1/manifests/validate { content | manifest } -> normalized summary."""user = require_admin_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)try:if 'content' in data:normalized = ManifestSpecService.normalize_text(data['content'])@@ -110,7 +111,7 @@ def get_manifest():def plan_manifest():"""POST /api/v1/manifests/plan {project_id, content|manifest?} -> dry-run plan."""user = require_admin_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)project = Project.query.get(data.get('project_id')) if data.get('project_id') else Noneif not project:return jsonify({'error': 'A valid project_id is required'}), 400@@ -128,7 +129,7 @@ def plan_manifest():def apply_manifest():"""POST /api/v1/manifests/apply {project_id, content|manifest?} -> apply."""user = require_admin_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)project = Project.query.get(data.get('project_id')) if data.get('project_id') else Noneif not project:return jsonify({'error': 'A valid project_id is required'}), 400@@ -172,7 +173,7 @@ def reset_bootstrap():typing the app name in `confirm`."""user = require_admin_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)app = (Application.query_active().filter_by(id=data.get('app_id')).first()if data.get('app_id') else None)if not app:diff --git a/backend/app/api/marketplace.py b/backend/app/api/marketplace.pyindex 488083e2..2ff3529f 100644--- a/backend/app/api/marketplace.py+++ b/backend/app/api/marketplace.py@@ -12,6 +12,7 @@ from app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import get_current_userfrom app.error_reporting import unexpected_response+from app.api._request import json_objectmarketplace_bp = Blueprint('marketplace', __name__)@@ -55,7 +56,7 @@ def install_registry(slug):if entry is not None and entry.get('trust') == 'unreviewed' \and not registry_service._show_unreviewed():return jsonify({'error': 'Extension not found in the registry'}), 404- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)trust = (entry or {}).get('trust', 'unreviewed')acknowledged = body.get('acknowledge_risk') is True# Consent gate (shared with the update path — audits M2/M3):diff --git a/backend/app/api/mobile.py b/backend/app/api/mobile.pyindex 44086dd7..5b2a6e78 100644--- a/backend/app/api/mobile.py+++ b/backend/app/api/mobile.py@@ -1,8 +1,9 @@-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.models.user import Userfrom app import dbfrom app.exceptions import not_found+from app.api._request import json_objectmobile_bp = Blueprint('mobile', __name__)@@ -12,7 +13,7 @@ mobile_bp = Blueprint('mobile', __name__)def register_push():"""Register a device for push notifications."""user_id = get_jwt_identity()- data = request.get_json() or {}+ data = json_object()subscription = data.get('subscription')device_name = data.get('device_name', 'Unknown')@@ -45,7 +46,7 @@ def register_push():@jwt_required()def unregister_push():"""Unregister a device from push notifications."""- data = request.get_json() or {}+ data = json_object()endpoint = data.get('endpoint')if not endpoint:return jsonify({'error': 'endpoint required'}), 400@@ -69,7 +70,7 @@ def get_quick_actions():@jwt_required()def execute_quick_action(action_id):"""Execute a quick action."""- data = request.get_json() or {}+ data = json_object()if action_id == 'view_stats':# MonitoringService owns the live-metrics probe; ServerMetricsServicediff --git a/backend/app/api/modules.py b/backend/app/api/modules.pyindex 6ae59ab8..a6c9182f 100644--- a/backend/app/api/modules.py+++ b/backend/app/api/modules.py@@ -3,13 +3,14 @@Read is available to any authenticated user (the frontend needs it to hide navand guard routes); flipping a toggle is admin-only."""-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services import module_servicefrom app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import get_current_user+from app.api._request import json_objectmodules_bp = Blueprint('modules', __name__)@@ -31,7 +32,7 @@ def set_module(name):if name not in module_service.MODULES:return jsonify({'error': f'Unknown module: {name}'}), 404- data = request.get_json() or {}+ data = json_object()if 'enabled' not in data:return jsonify({'error': 'enabled (boolean) required'}), 400diff --git a/backend/app/api/monitoring.py b/backend/app/api/monitoring.pyindex aa5842c0..d6f8ca56 100644--- a/backend/app/api/monitoring.py+++ b/backend/app/api/monitoring.py@@ -2,6 +2,7 @@ from flask import Blueprint, request, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.middleware.rbac import admin_requiredfrom app.services.monitoring_service import MonitoringService+from app.api._request import json_objectmonitoring_bp = Blueprint('monitoring', __name__)@@ -62,7 +63,7 @@ def get_config():@admin_requireddef update_config():"""Update monitoring configuration."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400diff --git a/backend/app/api/monitors.py b/backend/app/api/monitors.pyindex a4493572..5824f9aa 100644--- a/backend/app/api/monitors.py+++ b/backend/app/api/monitors.py@@ -12,6 +12,7 @@ from flask_jwt_extended import jwt_requiredfrom app.exceptions import NotFoundErrorfrom app.middleware.rbac import permission_requiredfrom app.services.monitor_service import MonitorService+from app.api._request import json_objectmonitors_bp = Blueprint('monitors', __name__)@@ -98,7 +99,7 @@ def run_check(monitor_id):@monitors_bp.route('/<int:monitor_id>/pause', methods=['POST'])@permission_required('monitoring', 'write')def set_paused(monitor_id):- data = request.get_json() or {}+ data = json_object()monitor = MonitorService.set_paused(monitor_id, data.get('paused', True))if not monitor:return {'error': 'Monitor not found'}, 404@@ -151,7 +152,7 @@ def list_incidents():@monitors_bp.route('/incidents', methods=['POST'])@permission_required('monitoring', 'write')def create_incident():- data = request.get_json() or {}+ data = json_object()if not data.get('title'):return {'error': 'Incident title is required'}, 400incident = MonitorService.create_incident(data.get('page_id'), data)diff --git a/backend/app/api/nginx.py b/backend/app/api/nginx.pyindex f63a9dc2..e9951b19 100644--- a/backend/app/api/nginx.py+++ b/backend/app/api/nginx.py@@ -1,6 +1,7 @@-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom app.middleware.rbac import admin_requiredfrom app.services.nginx_service import NginxService+from app.api._request import json_objectnginx_bp = Blueprint('nginx', __name__)@@ -49,7 +50,7 @@ def list_sites():@admin_requireddef create_site():"""Create a new Nginx site configuration."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -99,7 +100,7 @@ def delete_site(name):@admin_requireddef add_ssl_to_site(name):"""Add SSL configuration to a site."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400diff --git a/backend/app/api/nginx_advanced.py b/backend/app/api/nginx_advanced.pyindex c44f8f93..72fcfac6 100644--- a/backend/app/api/nginx_advanced.py+++ b/backend/app/api/nginx_advanced.py@@ -2,6 +2,7 @@ from flask import Blueprint, request, jsonifyfrom flask_jwt_extended import jwt_requiredfrom app.services.nginx_advanced_service import NginxAdvancedServicefrom app.middleware.rbac import get_current_user+from app.api._request import json_objectnginx_advanced_bp = Blueprint('nginx_advanced', __name__)@@ -43,7 +44,7 @@ def preview_diff():user = get_current_user()if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()domain = data.get('domain')new_config = data.get('config', '')if not domain:diff --git a/backend/app/api/notifications.py b/backend/app/api/notifications.pyindex 3d0afb35..cd6ddb7d 100644--- a/backend/app/api/notifications.py+++ b/backend/app/api/notifications.py@@ -12,6 +12,7 @@ from app.services.settings_service import SettingsServicefrom app.services.bounce_service import BounceServicefrom app.notifications.service import NotificationBusServicefrom app.notifications.providers import EmailProviderService, SUPPORTED as EMAIL_PROVIDERS+from app.api._request import json_object# Header carrying the provider's HMAC-SHA256 of the raw request body, formatted# as ``sha256=<hexdigest>`` (GitHub-style). The shared secret is@@ -63,7 +64,7 @@ def get_config():@admin_requireddef update_channel_config(channel):"""Update configuration for a specific notification channel."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -178,7 +179,7 @@ def get_user_preferences():def update_user_preferences():"""Update current user's notification preferences."""current_user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -402,7 +403,7 @@ def list_chat_connections():def add_chat_connection():"""Create a chat/webhook connection (destination + secret encrypted)."""from app.services.chat_webhook_service import ChatWebhookService- data = request.get_json() or {}+ data = json_object()data['created_by'] = int(get_jwt_identity())try:conn = ChatWebhookService.add(data)@@ -503,7 +504,7 @@ def test_email_provider(provider_id):@admin_requireddef update_email_provider(provider_id):"""Update a provider's usage flags (uses_notifications / uses_relay /- relay_priority) — §6 unification. uses_relay applies only to SMTP."""+ relay_priority). uses_relay applies only to SMTP."""row = EmailProviderService.update_usage(provider_id, request.get_json() or {})if row is None:return jsonify({'error': 'Provider not found'}), 404diff --git a/backend/app/api/pairing.py b/backend/app/api/pairing.pyindex 1239ae54..eb909e6c 100644--- a/backend/app/api/pairing.py+++ b/backend/app/api/pairing.py@@ -25,6 +25,7 @@ from app.services.pairing_service import (AlreadyClaimedError,ExpiredEnrollmentError,)+from app.api._request import json_objectpairing_bp = Blueprint('pairing', __name__)@@ -34,7 +35,7 @@ def _enrollment_creds():enrollment_id = request.headers.get('X-Enrollment-Id')enrollment_secret = request.headers.get('X-Enrollment-Secret')if not enrollment_id and request.is_json:- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)enrollment_id = body.get('enrollment_id')enrollment_secret = body.get('enrollment_secret')return enrollment_id, enrollment_secret@@ -50,7 +51,7 @@ def _error_response(exc: PairingError):@pairing_bp.route('/enroll', methods=['POST'])@limiter.limit("10 per minute")def enroll():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)pubkey = data.get('pubkey')passphrase = data.get('passphrase')machine_id = data.get('machine_id')@@ -79,7 +80,7 @@ def enroll():@limiter.limit("30 per minute")def code_refresh():enrollment_id, enrollment_secret = _enrollment_creds()- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)force = bool(body.get('force', False))try:result = pairing_service.rotate_code(enrollment_id, enrollment_secret, force=force)@@ -92,7 +93,7 @@ def code_refresh():@limiter.limit("30 per minute")def code_freeze():enrollment_id, enrollment_secret = _enrollment_creds()- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)frozen = bool(body.get('frozen', True))try:result = pairing_service.set_freeze(enrollment_id, enrollment_secret, frozen=frozen)@@ -149,7 +150,7 @@ def poll():@limiter.limit("20 per minute")def lookup():"""Pre-flight: confirm a code exists (without revealing details)."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)code = data.get('code', '')pending = pairing_service.find_by_code(code)if not pending:@@ -167,7 +168,7 @@ def lookup():@limiter.limit("5 per 10 minute")def claim():user_id = int(get_jwt_identity())- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)code = data.get('code')passphrase = data.get('passphrase')name = data.get('name')diff --git a/backend/app/api/php.py b/backend/app/api/php.pyindex 7cdbb155..6cab1356 100644--- a/backend/app/api/php.py+++ b/backend/app/api/php.py@@ -1,6 +1,7 @@-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom app.middleware.rbac import admin_requiredfrom app.services.php_service import PHPService+from app.api._request import json_objectphp_bp = Blueprint('php', __name__)@@ -30,7 +31,7 @@ def install_version(version):@admin_requireddef set_default_version():"""Set default PHP version."""- data = request.get_json()+ data = json_object()version = data.get('version') if data else Noneif not version:@@ -52,7 +53,7 @@ def get_extensions(version):@admin_requireddef install_extension(version):"""Install a PHP extension."""- data = request.get_json()+ data = json_object()extension = data.get('extension') if data else Noneif not extension:@@ -74,7 +75,7 @@ def get_pools(version):@admin_requireddef create_pool(version):"""Create a new FPM pool."""- data = request.get_json()+ data = json_object()if not data or 'name' not in data:return jsonify({'error': 'Pool name is required'}), 400diff --git a/backend/app/api/plugins.py b/backend/app/api/plugins.pyindex 8dd758a6..2d753db5 100644--- a/backend/app/api/plugins.py+++ b/backend/app/api/plugins.py@@ -12,6 +12,7 @@ from app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import get_current_userfrom app.error_reporting import unexpected_response+from app.api._request import json_objectplugins_bp = Blueprint('plugins', __name__)@@ -54,7 +55,7 @@ def install_plugin():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json()+ data = json_object()if not data or 'url' not in data:return jsonify({'error': 'url required'}), 400@@ -119,7 +120,7 @@ def preview_plugin():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()url = (data.get('url') or '').strip()if not url:return jsonify({'error': 'url required'}), 400@@ -152,7 +153,7 @@ def install_plugin_local():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()path = (data.get('path') or '').strip()if not path:return jsonify({'error': 'path required'}), 400@@ -247,7 +248,7 @@ def uninstall_plugin(plugin_id):# ?purge=true or a JSON body {"purge": true}.purge = str(request.args.get('purge', '')).lower() in ('1', 'true', 'yes')if not purge:- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)purge = bool(body.get('purge'))plugin_name = plugin.name@@ -614,7 +615,7 @@ def update_plugin_config(plugin_id):if not plugin:return jsonify({'error': 'Plugin not found'}), 404- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)config = data.get('config')if not isinstance(config, dict):return jsonify({'error': 'config must be an object'}), 400@@ -681,7 +682,7 @@ def update_plugin_route(plugin_id):and not registry_service._show_unreviewed():return jsonify({'error': 'Extension not found in the registry'}), 404- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)acknowledged = body.get('acknowledge_risk') is Truereason, message = registry_service.consent_gate(entry, acknowledged)if reason:diff --git a/backend/app/api/private_urls.py b/backend/app/api/private_urls.pyindex bb5e8374..58babe96 100644--- a/backend/app/api/private_urls.py+++ b/backend/app/api/private_urls.py@@ -2,7 +2,7 @@# seam (can_access_app for reads, can_edit_app for mutations)."""API endpoints for managing private URLs for applications."""-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app import dbfrom app.models import Application, User@@ -10,6 +10,7 @@ from app.services.private_url_service import PrivateURLServicefrom app.services.nginx_service import NginxServicefrom app.services.resource_grant_service import ResourceGrantServicefrom app.exceptions import not_found, permission_denied+from app.api._request import json_objectprivate_urls_bp = Blueprint('private_urls', __name__)@@ -45,7 +46,7 @@ def enable_private_url(app_id):'private_url': f'/p/{app.private_slug}'}), 400- data = request.get_json() or {}+ data = json_object()custom_slug = data.get('slug')if custom_slug:@@ -132,7 +133,7 @@ def update_private_url(app_id):if not app.private_url_enabled:return jsonify({'error': 'Private URL is not enabled for this service'}), 400- data = request.get_json()+ data = json_object()if not data or 'slug' not in data:return jsonify({'error': 'Slug is required'}), 400diff --git a/backend/app/api/processes.py b/backend/app/api/processes.pyindex 72953395..4e94908d 100644--- a/backend/app/api/processes.py+++ b/backend/app/api/processes.py@@ -1,6 +1,7 @@from flask import Blueprint, request, jsonifyfrom app.middleware.rbac import admin_requiredfrom app.services.process_service import ProcessService+from app.api._request import json_objectprocesses_bp = Blueprint('processes', __name__)@@ -47,7 +48,7 @@ def get_services():@admin_requireddef control_service(service_name):"""Control a system service."""- data = request.get_json()+ data = json_object()action = data.get('action') if data else Noneif not action:diff --git a/backend/app/api/projects.py b/backend/app/api/projects.pyindex e04ff03e..b745e04b 100644--- a/backend/app/api/projects.py+++ b/backend/app/api/projects.py@@ -15,6 +15,7 @@ from app.services.workspace_service import WorkspaceServicefrom app.middleware.rbac import get_current_userfrom app.exceptions import permission_deniedfrom app.api._access import visible_workspace_ids+from app.api._request import json_objectprojects_bp = Blueprint('projects', __name__)@@ -54,7 +55,7 @@ def list_projects():def create_project():"""Create a project (auto-creates a default environment)."""user = get_current_user()- data = request.get_json() or {}+ data = json_object()name = (data.get('name') or '').strip()if not name:return jsonify({'error': 'Project name is required'}), 400@@ -109,7 +110,7 @@ def update_project(project_id):if not WorkspaceService.can_write_in_workspace(user, project.workspace_id):return jsonify({'error': 'You have read-only access to this workspace'}), 403- data = request.get_json() or {}+ data = json_object()updated = ProjectService.update_project(project_id,name=data.get('name'),diff --git a/backend/app/api/proxy.py b/backend/app/api/proxy.pyindex 3d3b3ac3..7d0e94b1 100644--- a/backend/app/api/proxy.py+++ b/backend/app/api/proxy.py@@ -16,6 +16,7 @@ from flask_jwt_extended import jwt_requiredfrom app.models.server import Serverfrom app.middleware.rbac import developer_requiredfrom app.services.proxy_stack_service import ProxyStackService+from app.api._request import json_objectproxy_bp = Blueprint('proxy', __name__)@@ -114,7 +115,7 @@ def configure_proxy(server_id):if err:return err- data = request.get_json() or {}+ data = json_object()proxy_type = data.get('proxy_type')custom_snippet = data.get('custom_snippet')@@ -142,7 +143,7 @@ def regenerate_proxy(server_id):if err:return err- data = request.get_json() or {}+ data = json_object()sites = data.get('sites')result = ProxyStackService.regenerate(server_id, sites=sites)status = 200 if result.get('success') else 502@@ -157,7 +158,7 @@ def switch_proxy(server_id):if err:return err- data = request.get_json() or {}+ data = json_object()proxy_type = data.get('proxy_type')if not proxy_type:return jsonify({'error': 'proxy_type is required'}), 400diff --git a/backend/app/api/python.py b/backend/app/api/python.pyindex 2cf3c69b..b884b013 100644--- a/backend/app/api/python.py+++ b/backend/app/api/python.py@@ -1,13 +1,14 @@# Bucket: PER-APP. Per-app Python runtime routes gate on the shared# app-access seam (can_access_app for reads, can_edit_app for mutations);# host-level interpreter management stays admin-only.-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.middleware.rbac import admin_requiredfrom app.models import User, Applicationfrom app.services.python_service import PythonServicefrom app import dbfrom app.exceptions import not_found, permission_denied+from app.api._request import json_objectpython_bp = Blueprint('python', __name__)@@ -51,7 +52,7 @@ def get_versions():@admin_requireddef create_flask_app():"""Create a new Flask application."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -110,7 +111,7 @@ def create_flask_app():@admin_requireddef create_django_app():"""Create a new Django application."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -202,7 +203,7 @@ def install_packages(app_id):if error:return jsonify(error[0]), error[1]- data = request.get_json()+ data = json_object()packages = data.get('packages') if data else Noneresult = PythonService.install_requirements(app.root_path, packages)@@ -255,7 +256,7 @@ def set_env_vars(app_id):if error:return jsonify(error[0]), error[1]- data = request.get_json()+ data = json_object()if not data or 'env_vars' not in data:return jsonify({'error': 'env_vars is required'}), 400@@ -364,7 +365,7 @@ def update_gunicorn_config(app_id):if error:return jsonify(error[0]), error[1]- data = request.get_json()+ data = json_object()if not data or 'content' not in data:return jsonify({'error': 'content is required'}), 400@@ -412,7 +413,7 @@ def run_command(app_id):if error:return jsonify(error[0]), error[1]- data = request.get_json()+ data = json_object()if not data or 'command' not in data:return jsonify({'error': 'command is required'}), 400@@ -436,7 +437,7 @@ def delete_app(app_id):if error:return jsonify(error[0]), error[1]- data = request.get_json() or {}+ data = json_object()remove_files = data.get('remove_files', False)result = PythonService.delete_app(app.name, app.root_path, remove_files)diff --git a/backend/app/api/queue_bus.py b/backend/app/api/queue_bus.pyindex 8f308623..1f9dccfc 100644--- a/backend/app/api/queue_bus.py+++ b/backend/app/api/queue_bus.py@@ -4,6 +4,7 @@ from flask_jwt_extended import jwt_requiredfrom app.queue_bus.service import QueueBusService, QueueBusErrorfrom app.middleware.rbac import get_current_user+from app.api._request import json_objectqueue_bus_bp = Blueprint('queue_bus', __name__)@@ -69,7 +70,7 @@ def list_groups():@queue_bus_bp.route('/groups', methods=['POST'])@jwt_required()def create_group():- data = request.get_json() or {}+ data = json_object()slug = data.get('slug')name = data.get('name')description = data.get('description')@@ -111,7 +112,7 @@ def get_group(group_slug):def update_group(group_slug):_ensure_group_mutable(group_slug)_ensure_group_accessible(group_slug)- data = request.get_json() or {}+ data = json_object()group = QueueBusService.update_group(slug=group_slug,name=data.get('name'),@@ -148,7 +149,7 @@ def list_queues(group_slug):def create_queue(group_slug):_ensure_group_mutable(group_slug)_ensure_group_accessible(group_slug)- data = request.get_json() or {}+ data = json_object()slug = data.get('slug')name = data.get('name')description = data.get('description')@@ -181,7 +182,7 @@ def get_queue(group_slug, queue_slug):def update_queue(group_slug, queue_slug):_ensure_group_mutable(group_slug)_ensure_group_accessible(group_slug)- data = request.get_json() or {}+ data = json_object()queue = QueueBusService.update_queue(group_slug=group_slug,slug=queue_slug,@@ -227,7 +228,7 @@ def list_messages(group_slug, queue_slug):def send_message(group_slug, queue_slug):_ensure_group_mutable(group_slug)_ensure_group_accessible(group_slug)- data = request.get_json() or {}+ data = json_object()payload = data.get('payload')priority = data.get('priority', 0)delay_ms = data.get('delay_ms', 0)@@ -251,7 +252,7 @@ def send_message(group_slug, queue_slug):@jwt_required()def receive_messages(group_slug, queue_slug):_ensure_group_accessible(group_slug)- data = request.get_json() or {}+ data = json_object()visibility_timeout_ms = data.get('visibility_timeout_ms', 30000)max_messages = data.get('max_messages', 1)@@ -286,7 +287,7 @@ def complete_message(group_slug, queue_slug, message_id):@jwt_required()def fail_message(group_slug, queue_slug, message_id):_ensure_group_accessible(group_slug)- data = request.get_json() or {}+ data = json_object()message = QueueBusService.fail(group_slug=group_slug,queue_slug=queue_slug,diff --git a/backend/app/api/recipes.py b/backend/app/api/recipes.pyindex c0c1006e..ab1f23bc 100644--- a/backend/app/api/recipes.py+++ b/backend/app/api/recipes.py@@ -23,6 +23,7 @@ from app.services.recipe_execution_service import (RECIPE_JOB_KIND,RecipeExecutionService,)+from app.api._request import json_objectrecipes_bp = Blueprint('recipes', __name__)@@ -89,7 +90,7 @@ def get_recipe_registry_entry(slug):@recipes_bp.route('/runs', methods=['POST'])@admin_requireddef start_recipe_run():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)project = Noneserver = None@@ -164,7 +165,7 @@ def submit_recipe_handoff(job_id, step_id):job = DeploymentJob.query.get(job_id)if not job or job.kind != RECIPE_JOB_KIND:return jsonify({'error': 'Recipe run not found'}), 404- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)user = get_current_user()wait = request.args.get('wait', 'false').lower() == 'true'result = RecipeExecutionService.submit_handoff(diff --git a/backend/app/api/recycle_bin.py b/backend/app/api/recycle_bin.pyindex dd0df2db..f5a1b088 100644--- a/backend/app/api/recycle_bin.py+++ b/backend/app/api/recycle_bin.py@@ -9,6 +9,7 @@ from flask_jwt_extended import jwt_required, get_jwt_identityfrom app.middleware.rbac import admin_requiredfrom app.exceptions import NotFoundErrorfrom app.services import recycle_bin_service+from app.api._request import json_objectrecycle_bin_bp = Blueprint('recycle_bin', __name__)@@ -63,7 +64,7 @@ def purge(kind, record_id):@recycle_bin_bp.route('/purge-expired', methods=['POST'])@admin_requireddef purge_expired():- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)days = body.get('retention_days', recycle_bin_service.DEFAULT_RETENTION_DAYS)try:days = max(1, int(days))diff --git a/backend/app/api/security.py b/backend/app/api/security.pyindex 2d83446d..25d35a6e 100644--- a/backend/app/api/security.py+++ b/backend/app/api/security.py@@ -14,6 +14,7 @@ from flask_jwt_extended import jwt_requiredfrom app.middleware.rbac import admin_requiredfrom app.services.security_service import SecurityServicefrom app.error_reporting import unexpected_response+from app.api._request import json_objectsecurity_bp = Blueprint('security', __name__)@@ -41,7 +42,7 @@ def get_config():@admin_requireddef update_config():"""Update security configuration."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -63,7 +64,7 @@ def update_config():@admin_requireddef initialize_integrity():"""Create baseline for file integrity monitoring."""- data = request.get_json() or {}+ data = json_object()paths = data.get('paths')result = SecurityService.initialize_integrity_database(paths)return jsonify(result), 200 if result['success'] else 400@@ -117,7 +118,7 @@ def get_ssh_keys():@admin_requireddef add_ssh_key():"""Add an SSH public key."""- data = request.get_json()+ data = json_object()if not data or 'key' not in data:return jsonify({'error': 'SSH key required'}), 400@@ -150,7 +151,7 @@ def get_ip_lists():@admin_requireddef add_to_ip_list(list_type):"""Add IP to allowlist or blocklist."""- data = request.get_json()+ data = json_object()if not data or 'ip' not in data:return jsonify({'error': 'IP address required'}), 400@@ -199,7 +200,7 @@ def fim_baseline(scope):from app.services.file_integrity_service import (FileIntegrityService, FileIntegrityScopeError,)- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)options = data.get('options') if isinstance(data.get('options'), dict) else Nonetry:result = FileIntegrityService.baseline(scope, options=options)diff --git a/backend/app/api/server_templates.py b/backend/app/api/server_templates.pyindex 5ce4d069..2c189500 100644--- a/backend/app/api/server_templates.py+++ b/backend/app/api/server_templates.py@@ -5,6 +5,7 @@ from app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import admin_required, get_current_userfrom app.exceptions import not_found+from app.api._request import json_objectserver_templates_bp = Blueprint('server_templates', __name__)@@ -52,7 +53,7 @@ def create_template():if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json()+ data = json_object()if not data or 'name' not in data:return jsonify({'error': 'name required'}), 400@@ -106,7 +107,7 @@ def assign_template(template_id):if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()server_id = data.get('server_id')if not server_id:return jsonify({'error': 'server_id required'}), 400@@ -125,7 +126,7 @@ def bulk_assign(template_id):if not user or not user.is_admin:return jsonify({'error': 'Admin access required'}), 403- data = request.get_json() or {}+ data = json_object()server_ids = data.get('server_ids', [])results = ServerTemplateService.bulk_assign(template_id, server_ids)return jsonify({'results': results})diff --git a/backend/app/api/servers.py b/backend/app/api/servers.pyindex 2976a95b..04023738 100644--- a/backend/app/api/servers.py+++ b/backend/app/api/servers.py@@ -201,7 +201,7 @@ def list_groups():@developer_requireddef create_group():"""Create a new server group"""- data = request.get_json()+ data = json_object()if not data.get('name'):raise field_required('Name')@@ -360,7 +360,7 @@ def create_server():description, group_id, tags, permissions, permission_profile,allowed_ips: passed through unchanged."""- data = request.get_json() or {}+ data = json_object()# Through the one identity door: @developer_required admits API-key# callers, for whom reading the JWT directly raises.creator = get_current_user()@@ -697,7 +697,7 @@ def regenerate_token(server_id):"""server = _get_operable_server(server_id)- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)expires_at = _resolve_token_expiry(data.get('expires_in'))registration_token = Server.generate_registration_token()diff --git a/backend/app/api/servers_agents.py b/backend/app/api/servers_agents.pyindex 3686c603..368b8200 100644--- a/backend/app/api/servers_agents.py+++ b/backend/app/api/servers_agents.py@@ -347,7 +347,7 @@ def check_agent_version():"arch": "amd64"}"""- data = request.get_json() or {}+ data = json_object()current_version = data.get('current_version', '0.0.0')agent_os = data.get('os', 'linux')agent_arch = data.get('arch', 'amd64')@@ -542,7 +542,7 @@ def list_agent_versions():@admin_requireddef add_agent_version():"""Add a new available agent version"""- data = request.get_json()+ data = json_object()if not data.get('version'):raise field_required('Version')diff --git a/backend/app/api/servers_docker.py b/backend/app/api/servers_docker.pyindex 9c207e07..c4cf96eb 100644--- a/backend/app/api/servers_docker.py+++ b/backend/app/api/servers_docker.py@@ -7,6 +7,7 @@ from app.exceptions import field_requiredfrom flask_jwt_extended import get_jwt_identity, jwt_requiredfrom flask import jsonify, requestfrom app.api.servers import _agent_failure_status, servers_bp+from app.api._request import json_object# ==================== Remote Docker Operations ====================@@ -68,7 +69,7 @@ def start_remote_container(server_id, container_id):def stop_remote_container(server_id, container_id):"""Stop a container on a remote server"""user_id = get_jwt_identity()- data = request.get_json() or {}+ data = json_object()timeout = data.get('timeout')result = RemoteDockerService.stop_container(server_id, container_id, timeout=timeout, user_id=user_id)@@ -84,7 +85,7 @@ def stop_remote_container(server_id, container_id):def restart_remote_container(server_id, container_id):"""Restart a container on a remote server"""user_id = get_jwt_identity()- data = request.get_json() or {}+ data = json_object()timeout = data.get('timeout')result = RemoteDockerService.restart_container(server_id, container_id, timeout=timeout, user_id=user_id)@@ -176,7 +177,7 @@ def list_remote_images(server_id):def pull_remote_image(server_id):"""Pull an image on a remote server"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('image'):return jsonify({'error': 'Image name required'}), 400@@ -310,7 +311,7 @@ def list_remote_compose_projects(server_id):def remote_compose_ps(server_id):"""List containers for a compose project"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('project_path'):raise field_required('project_path')@@ -332,7 +333,7 @@ def remote_compose_ps(server_id):def remote_compose_up(server_id):"""Start a compose project"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('project_path'):raise field_required('project_path')@@ -356,7 +357,7 @@ def remote_compose_up(server_id):def remote_compose_down(server_id):"""Stop a compose project"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('project_path'):raise field_required('project_path')@@ -380,7 +381,7 @@ def remote_compose_down(server_id):def remote_compose_logs(server_id):"""Get logs from a compose project"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('project_path'):raise field_required('project_path')@@ -404,7 +405,7 @@ def remote_compose_logs(server_id):def remote_compose_restart(server_id):"""Restart a compose project or specific service"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('project_path'):raise field_required('project_path')@@ -427,7 +428,7 @@ def remote_compose_restart(server_id):def remote_compose_pull(server_id):"""Pull images for a compose project"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('project_path'):raise field_required('project_path')diff --git a/backend/app/api/servers_remote.py b/backend/app/api/servers_remote.pyindex ca17caf0..21deee4a 100644--- a/backend/app/api/servers_remote.py+++ b/backend/app/api/servers_remote.py@@ -14,6 +14,7 @@ from app.exceptions import field_requiredfrom flask_jwt_extended import get_jwt_identity, jwt_requiredfrom flask import jsonify, requestfrom app.api.servers import _agent_failure_status, _get_operable_server, servers_bp+from app.api._request import json_object# ==================== Remote Terminal ====================@@ -29,7 +30,7 @@ def create_terminal_session(server_id):"""_get_operable_server(server_id)user_id = get_jwt_identity()- data = request.get_json() or {}+ data = json_object()cols = data.get('cols', 80)rows = data.get('rows', 24)@@ -56,7 +57,7 @@ def terminal_input(session_id):data: Base64-encoded input data"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('data'):raise field_required('data')@@ -83,7 +84,7 @@ def terminal_resize(session_id):rows: New terminal height"""user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data or not data.get('cols') or not data.get('rows'):return jsonify({'error': 'cols and rows are required'}), 400@@ -172,7 +173,7 @@ def remote_cron_list(server_id):@developer_requireddef remote_cron_add(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)schedule = (data.get('schedule') or '').strip()command = (data.get('command') or '').strip()if not schedule:@@ -201,7 +202,7 @@ def remote_cron_remove(server_id, job_id):@developer_requireddef remote_cron_toggle(server_id, job_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)enabled = bool(data.get('enabled', True))result = RemoteCronService.toggle_job(server_id, job_id, enabled, user_id=user_id)return _agent_result(result)@@ -251,7 +252,7 @@ def remote_cloudflared_list(server_id):@developer_requireddef remote_cloudflared_create(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)name = (data.get('name') or '').strip()if not name:raise field_required('name')@@ -264,7 +265,7 @@ def remote_cloudflared_create(server_id):@developer_requireddef remote_cloudflared_route(server_id, tunnel_ref):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)hostname = (data.get('hostname') or '').strip()if not hostname:raise field_required('hostname')@@ -357,7 +358,7 @@ def remote_packages_install(server_id):Returns {job_id, channel} immediately; the panel subscribes to thematching Socket.IO room for live install output."""user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)names = data.get('names') or []if isinstance(names, str):names = [names]@@ -371,7 +372,7 @@ def remote_packages_install(server_id):@developer_requireddef remote_packages_remove(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)name = (data.get('name') or '').strip()if not name:raise field_required('name')@@ -385,7 +386,7 @@ def remote_packages_upgrade(server_id):"""Streaming upgrade. Body: {all: bool, names?: [...]}. Returns{job_id, channel}."""user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)names = data.get('names') or []all_pkgs = bool(data.get('all', False))if not all_pkgs and not names:@@ -502,7 +503,7 @@ def remote_runtimes_python_current(server_id):@developer_requireddef remote_runtimes_python_install(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)version = (data.get('version') or '').strip()if not version:raise field_required('version')@@ -514,7 +515,7 @@ def remote_runtimes_python_install(server_id):@developer_requireddef remote_runtimes_python_uninstall(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)version = (data.get('version') or '').strip()if not version:raise field_required('version')@@ -526,7 +527,7 @@ def remote_runtimes_python_uninstall(server_id):@developer_requireddef remote_runtimes_python_set_global(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)version = (data.get('version') or '').strip()if not version:raise field_required('version')@@ -538,7 +539,7 @@ def remote_runtimes_python_set_global(server_id):@developer_requireddef remote_runtimes_python_set_local(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)version = (data.get('version') or '').strip()dir_path = (data.get('dir') or '').strip()if not version or not dir_path:@@ -591,7 +592,7 @@ def remote_file_read(server_id):@developer_requireddef remote_file_write(server_id):user_id = get_jwt_identity()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)path = (data.get('path') or '').strip()content = data.get('content')if not path:diff --git a/backend/app/api/setup_health.py b/backend/app/api/setup_health.pyindex 64b33e09..92a6711e 100644--- a/backend/app/api/setup_health.py+++ b/backend/app/api/setup_health.py@@ -21,6 +21,7 @@ from ..services.setup_reconcile_service import (URL_FIX_JOB_KIND,SetupReconcileService,)+from app.api._request import json_objectsetup_health_bp = Blueprint('setup_health', __name__)@@ -68,7 +69,7 @@ def _snooze_guard(key):@auth_required()def snooze_item():"""Snooze a setup item (mutes it; it still renders, just quietly)."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)key = data.get('key')if not key:return jsonify({'error': "Body must carry an item 'key'."}), 400@@ -82,7 +83,7 @@ def snooze_item():@auth_required()def unsnooze_item():"""Clear a snooze so the item is active again."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)key = data.get('key') or request.args.get('key')if not key:return jsonify({'error': "An item 'key' is required."}), 400diff --git a/backend/app/api/shared_resources.py b/backend/app/api/shared_resources.pyindex 5a164a47..bad1ec4e 100644--- a/backend/app/api/shared_resources.py+++ b/backend/app/api/shared_resources.py@@ -15,6 +15,7 @@ from app.services.resource_grant_service import ResourceGrantServicefrom app.services.shared_resource_service import SharedResourceServicefrom app.models.shared_resource import SharedVariableGroupfrom app.utils.sensitive_data_filter import mask_sensitive+from app.api._request import json_objectshared_resources_bp = Blueprint('shared_resources', __name__)@@ -204,7 +205,7 @@ def list_tags():@shared_resources_bp.route('/tags', methods=['POST'])@jwt_required()def add_tag():- data = request.get_json() or {}+ data = json_object()missing = _require(data, 'resource_type', 'resource_id', 'tag')if missing:return _bad(f'{missing} is required')@@ -224,7 +225,7 @@ def add_tag():@jwt_required()def remove_tag():# Accept either body or query params for convenience.- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)resource_type = data.get('resource_type') or request.args.get('resource_type')resource_id = data.get('resource_id')if resource_id is None:@@ -268,7 +269,7 @@ def list_groups():@shared_resources_bp.route('/variable-groups', methods=['POST'])@jwt_required()def create_group():- data = request.get_json() or {}+ data = json_object()missing = _require(data, 'scope_type', 'scope_id', 'name')if missing:return _bad(f'{missing} is required')@@ -302,7 +303,7 @@ def update_group(group_id):group, denied = _get_scoped_group(group_id, write=True)if denied:return denied- data = request.get_json() or {}+ data = json_object()try:group = SharedResourceService.update_group(group.id, name=data.get('name'), description=data.get('description')@@ -333,7 +334,7 @@ def add_variable(group_id):group, denied = _get_scoped_group(group_id, write=True)if denied:return denied- data = request.get_json() or {}+ data = json_object()if data.get('key') in (None, ''):return _bad('key is required')try:@@ -360,7 +361,7 @@ def update_variable(group_id, variable_id):existing = SharedVariable.query.get(variable_id)if not existing or existing.group_id != group.id:return _bad('variable not found', 404)- data = request.get_json() or {}+ data = json_object()_kwargs = {'value': data.get('value'), 'is_secret': data.get('is_secret')}if 'target_service' in data:# Only forward when the client sent it, so it's preserved otherwise.@@ -391,7 +392,7 @@ def delete_variable(group_id, variable_id):@shared_resources_bp.route('/variable-groups/<int:group_id>/attach', methods=['POST'])@jwt_required()def attach_group(group_id):- data = request.get_json() or {}+ data = json_object()missing = _require(data, 'resource_type', 'resource_id')if missing:return _bad(f'{missing} is required')@@ -412,7 +413,7 @@ def attach_group(group_id):@shared_resources_bp.route('/variable-groups/<int:group_id>/detach', methods=['POST'])@jwt_required()def detach_group(group_id):- data = request.get_json() or {}+ data = json_object()missing = _require(data, 'resource_type', 'resource_id')if missing:return _bad(f'{missing} is required')diff --git a/backend/app/api/site_imports.py b/backend/app/api/site_imports.pyindex e9789b84..f45b49e4 100644--- a/backend/app/api/site_imports.py+++ b/backend/app/api/site_imports.py@@ -8,6 +8,7 @@ from flask import Blueprint, jsonify, requestfrom app.middleware.rbac import admin_required, get_current_userfrom app.services.site_import_service import SiteImportError, SiteImportService+from app.api._request import json_objectsite_imports_bp = Blueprint('site_imports', __name__)@@ -35,7 +36,7 @@ def probe_ssh_source():"""Preflight an SSH import source: test the connection, list the docroot,sniff the stack. Linux-only runtime — returns 501 on a hostthat can't run ssh (e.g. Windows dev) so the wizard can message it."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)source = data.get('source') or datatry:result = SiteImportService.probe_ssh(source)@@ -49,7 +50,7 @@ def probe_ssh_source():@site_imports_bp.route('', methods=['POST'])@admin_requireddef create_import():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)user = get_current_user()try:imp = SiteImportService.create(@@ -100,7 +101,7 @@ def run_import(import_id):if imp.status not in ('analyzed', 'failed'):return jsonify({'error': "Import must be analysed before it can run "f"(status: {imp.status})"}), 409- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)from_step = data.get('from_step') or None# Merge wizard-provided run options into the stored ones (body wins),# e.g. {'skip_db': True, 'skip_crontab': True}.diff --git a/backend/app/api/source_connections.py b/backend/app/api/source_connections.pyindex 0e9ddc93..ebb0dddf 100644--- a/backend/app/api/source_connections.py+++ b/backend/app/api/source_connections.py@@ -6,6 +6,7 @@ from requests import HTTPErrorfrom app.middleware.rbac import admin_required, get_current_userfrom app.services.source_connection_service import SourceConnectionService+from app.api._request import json_objectsource_connections_bp = Blueprint('source_connections', __name__)@@ -35,7 +36,7 @@ def github_authorize():@jwt_required()def github_callback():user_id = int(get_jwt_identity())- data = request.get_json() or {}+ data = json_object()code = data.get('code', '')state = data.get('state', '')redirect_uri = data.get('redirect_uri', '')@@ -150,7 +151,7 @@ def github_app_manifest():def complete_github_app_manifest():"""Convert the manifest code GitHub returned into a stored GitHub App."""user = get_current_user()- data = request.get_json() or {}+ data = json_object()try:result = SourceConnectionService.complete_github_app_manifest(code=data.get('code', ''),@@ -200,7 +201,7 @@ def gitlab_authorize():@jwt_required()def gitlab_callback():user_id = int(get_jwt_identity())- data = request.get_json() or {}+ data = json_object()code = data.get('code', '')state = data.get('state', '')redirect_uri = data.get('redirect_uri', '')@@ -332,7 +333,7 @@ def bitbucket_authorize():@jwt_required()def bitbucket_callback():user_id = int(get_jwt_identity())- data = request.get_json() or {}+ data = json_object()code = data.get('code', '')state = data.get('state', '')redirect_uri = data.get('redirect_uri', '')diff --git a/backend/app/api/ssl.py b/backend/app/api/ssl.pyindex 8a3f3d4b..fe719e31 100644--- a/backend/app/api/ssl.py+++ b/backend/app/api/ssl.py@@ -1,7 +1,8 @@-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.middleware.rbac import admin_requiredfrom app.services.ssl_service import SSLService, get_acme_contact, remember_acme_contact+from app.api._request import json_objectssl_bp = Blueprint('ssl', __name__)@@ -41,7 +42,7 @@ def get_certificate(domain):@admin_requireddef obtain_certificate():"""Obtain a new SSL certificate from Let's Encrypt."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400diff --git a/backend/app/api/sso.py b/backend/app/api/sso.pyindex ec7e63c1..d8a831aa 100644--- a/backend/app/api/sso.py+++ b/backend/app/api/sso.py@@ -14,6 +14,7 @@ from app.middleware.rbac import admin_required, get_current_userfrom app.middleware.session_auth import issue_session_tokensfrom app.error_reporting import record_unexpectedfrom app.exceptions import NotFoundError+from app.api._request import json_objectsso_bp = Blueprint('sso', __name__)@@ -56,7 +57,7 @@ def callback(provider):if provider not in VALID_PROVIDERS or provider == 'saml':return jsonify({'error': f'Invalid OAuth provider: {provider}'}), 400- data = request.get_json() or {}+ data = json_object()code = data.get('code', '')state = data.get('state', '')redirect_uri = data.get('redirect_uri', '')@@ -158,7 +159,7 @@ def link_provider(provider):return jsonify({'error': f'Invalid provider: {provider}'}), 400user_id = get_jwt_identity()- data = request.get_json() or {}+ data = json_object()code = data.get('code', '')state = data.get('state', '')redirect_uri = data.get('redirect_uri', '')@@ -232,7 +233,7 @@ def update_provider_config(provider):if provider not in VALID_PROVIDERS:return jsonify({'error': f'Invalid provider: {provider}'}), 400- data = request.get_json() or {}+ data = json_object()prefix = f'sso_{provider}_'updated = []@@ -268,7 +269,7 @@ def update_general_settings():"""Update general SSO settings (auto_provision, force_sso, etc.)."""user = get_current_user()- data = request.get_json() or {}+ data = json_object()general_keys = ['sso_auto_provision', 'sso_default_role', 'sso_force_sso', 'sso_allowed_domains']updated = []diff --git a/backend/app/api/survey.py b/backend/app/api/survey.pyindex 0c4433d4..2f56d67b 100644--- a/backend/app/api/survey.py+++ b/backend/app/api/survey.py@@ -10,6 +10,7 @@ from app.middleware.rbac import admin_required, get_current_userfrom app.models.server import Serverfrom app.services import survey_servicefrom app.exceptions import not_found+from app.api._request import json_objectsurvey_bp = Blueprint('survey', __name__)@@ -54,7 +55,7 @@ def set_management_mode(server_id):if server is None:raise not_found('server')- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)mode = (data.get('mode') or '').strip().lower()if mode not in Server.MANAGEMENT_MODES:return jsonify({'error': f'mode must be one of {list(Server.MANAGEMENT_MODES)}'}), 400diff --git a/backend/app/api/system.py b/backend/app/api/system.pyindex 197a9747..fe77635f 100644--- a/backend/app/api/system.py+++ b/backend/app/api/system.py@@ -15,6 +15,7 @@ from app.services.site_domain_service import SiteDomainServicefrom app.utils.domain import is_valid_canonical_domainfrom app.utils.version import get_panel_version, get_install_dirfrom app.middleware.rbac import require_admin_user+from app.api._request import json_object# Cache for update check (to avoid hitting GitHub API too often)_update_cache = {@@ -124,7 +125,7 @@ def start_panel_update():Body must carry ``{"confirm": true}`` — this restarts the panel backend."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if data.get('confirm') is not True:raise ValidationError('Confirmation required: pass {"confirm": true}.')@@ -215,7 +216,7 @@ def reclaim_disk_space():``?wait=false`` enqueues the work as a background job instead of runningit inline — reclaims can take minutes when Docker or a VACUUM is involved."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)if data.get('confirm') is not True:raise ValidationError('Confirmation required: pass {"confirm": true}.')keys = data.get('keys')@@ -453,7 +454,7 @@ def set_capacity_profile():"""Record an operator's profile change made after install."""user = require_admin_user()- data = request.get_json() or {}+ data = json_object()profile = data.get('profile')try:@@ -487,7 +488,7 @@ def set_timezone():"""Set server timezone (admin only)."""require_admin_user()- data = request.get_json()+ data = json_object()if not data or 'timezone' not in data:return jsonify({'error': 'Timezone is required'}), 400diff --git a/backend/app/api/telemetry.py b/backend/app/api/telemetry.pyindex 0d00ed25..7a0ccf7f 100644--- a/backend/app/api/telemetry.py+++ b/backend/app/api/telemetry.py@@ -10,6 +10,7 @@ from app import dbfrom app.middleware.rbac import admin_requiredfrom app.models.system_event import SystemEventfrom app.services.telemetry_service import TelemetryService+from app.api._request import json_objecttelemetry_bp = Blueprint('telemetry', __name__)@@ -122,7 +123,7 @@ def cleanup_events():@admin_requireddef emit_test_event():"""Emit a test telemetry event (admin only)."""- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)user_id = get_jwt_identity()event = TelemetryService.emit(source=data.get('source', 'system'),diff --git a/backend/app/api/templates.py b/backend/app/api/templates.pyindex 6ef0b120..5525f52f 100644--- a/backend/app/api/templates.py+++ b/backend/app/api/templates.py@@ -20,6 +20,7 @@ from app.services.repository_manifest_service import RepositoryManifestServicefrom app.services.resource_grant_service import ResourceGrantServicefrom app.utils.slug import app_name_clash_error, validate_app_namefrom app.exceptions import not_found, permission_denied+from app.api._request import json_objecttemplates_bp = Blueprint('templates', __name__)@@ -315,7 +316,7 @@ def catalog_schema():def install_template(template_id):"""Install a template as a new application."""current_user_id = get_jwt_identity()- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -376,7 +377,7 @@ def template_capacity(template_id):@jwt_required()def validate_installation():"""Validate template installation parameters before installing."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -464,7 +465,7 @@ def test_db_connection():200: Connection successful400: Connection failed or missing parameters"""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -563,7 +564,7 @@ def list_repositories():@admin_requireddef add_repository():"""Add a template repository."""- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400@@ -582,7 +583,7 @@ def add_repository():@admin_requireddef remove_repository():"""Remove a template repository."""- data = request.get_json()+ data = json_object()url = data.get('url') if data else Noneif not url:diff --git a/backend/app/api/test_sandbox.py b/backend/app/api/test_sandbox.pyindex 13690f3a..d43d8ed0 100644--- a/backend/app/api/test_sandbox.py+++ b/backend/app/api/test_sandbox.py@@ -6,6 +6,7 @@ from flask import Blueprint, jsonify, requestfrom ..middleware.rbac import admin_required, viewer_requiredfrom ..services.test_sandbox_service import TestSandboxService+from app.api._request import json_objecttest_sandbox_bp = Blueprint('test_sandbox', __name__)@@ -30,7 +31,7 @@ def list_runs():@test_sandbox_bp.route('/runs', methods=['POST'])@admin_requireddef start_run():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)distros = data.get('distros') or []mode = data.get('mode', 'quick')try:diff --git a/backend/app/api/themes.py b/backend/app/api/themes.pyindex 263d479d..f119e921 100644--- a/backend/app/api/themes.py+++ b/backend/app/api/themes.py@@ -19,6 +19,7 @@ from app.services import theme_servicefrom app.services.audit_service import AuditServicefrom app.models.audit_log import AuditLogfrom app.middleware.rbac import require_admin_user+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -119,7 +120,7 @@ def set_default():"""Set the panel-wide default theme (admin) — what login/setup and newusers get before picking their own."""user = require_admin_user()- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)slug = body.get('slug')if not isinstance(slug, str) or not slug:return jsonify({'error': 'Missing slug'}), 400diff --git a/backend/app/api/two_factor.py b/backend/app/api/two_factor.pyindex 335ec72a..5597ea2e 100644--- a/backend/app/api/two_factor.py+++ b/backend/app/api/two_factor.py@@ -7,7 +7,7 @@ Provides endpoints for enabling, disabling, and managing 2FA.import loggingimport threadingimport time-from flask import Blueprint, request, jsonify+from flask import Blueprint, jsonifyfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app import limiterfrom app.middleware.session_auth import issue_session_tokens@@ -16,6 +16,7 @@ from app.services.totp_service import TOTPService, TwoFactorSetupfrom app.services import auth_throttle_servicefrom app.utils.client_ip import get_client_ipfrom app.exceptions import AuthenticationError, RateLimitedError, not_found+from app.api._request import json_objectlogger = logging.getLogger(__name__)@@ -106,7 +107,7 @@ def confirm_2fa_setup():if user.totp_enabled:return jsonify({'error': '2FA is already enabled'}), 400- data = request.get_json()+ data = json_object()if not data or 'code' not in data:return jsonify({'error': 'Verification code is required'}), 400@@ -138,7 +139,7 @@ def disable_2fa():if not user.totp_enabled:return jsonify({'error': '2FA is not enabled'}), 400- data = request.get_json()+ data = json_object()if not data or 'code' not in data:return jsonify({'error': 'Verification code is required'}), 400@@ -171,7 +172,7 @@ def regenerate_backup_codes():if not user.totp_enabled:return jsonify({'error': '2FA is not enabled'}), 400- data = request.get_json()+ data = json_object()if not data or 'code' not in data:return jsonify({'error': 'TOTP code is required'}), 400@@ -208,7 +209,7 @@ def verify_2fa_code():'error': 'Too many failed attempts. Try again later.'}), 429, {'Retry-After': str(retry_after)}- data = request.get_json()+ data = json_object()if not data:return jsonify({'error': 'No data provided'}), 400diff --git a/backend/app/api/views.py b/backend/app/api/views.pyindex 551be831..c7626edf 100644--- a/backend/app/api/views.py+++ b/backend/app/api/views.py@@ -2,6 +2,7 @@ from flask import Blueprint, jsonify, requestfrom flask_jwt_extended import jwt_required, get_jwt_identityfrom app.services import saved_view_service+from app.api._request import json_objectviews_bp = Blueprint('views', __name__)@@ -19,7 +20,7 @@ def list_views():@views_bp.route('', methods=['POST'])@jwt_required()def create_view():- body = request.get_json(silent=True) or {}+ body = json_object(optional=True)view = saved_view_service.create_view(get_jwt_identity(),body.get('page'),diff --git a/backend/app/api/waf.py b/backend/app/api/waf.pyindex 8b95c9ea..cf0fac0d 100644--- a/backend/app/api/waf.py+++ b/backend/app/api/waf.py@@ -12,6 +12,7 @@ from flask_jwt_extended import jwt_requiredfrom app.services.waf_service import WafServicefrom app.middleware.rbac import require_admin_userfrom app.api._access import require_app+from app.api._request import json_objectwaf_bp = Blueprint('waf', __name__)@@ -30,7 +31,7 @@ def update_policy(app_id):require_admin_user()require_app(app_id, conceal=True)- data = request.get_json() or {}+ data = json_object()try:policy = WafService.set_policy(app_id,diff --git a/backend/app/api/walkthroughs.py b/backend/app/api/walkthroughs.pyindex f4ac3dff..5ee9122a 100644--- a/backend/app/api/walkthroughs.py+++ b/backend/app/api/walkthroughs.py@@ -1,6 +1,6 @@"""Self-scoped guided walkthrough progress API."""-from flask import Blueprint, jsonify, request+from flask import Blueprint, jsonifyfrom app.middleware.rbac import admin_required, get_current_user, require_role, viewer_requiredfrom app.services.walkthrough_definition_service import (@@ -11,6 +11,7 @@ from app.services.walkthrough_service import (WalkthroughService,WalkthroughStateError,)+from app.api._request import json_objectwalkthroughs_bp = Blueprint('walkthroughs', __name__)@@ -27,7 +28,7 @@ def get_walkthrough_state():@require_role('admin', 'developer', 'viewer')def update_walkthrough_state():user = get_current_user()- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)try:state = WalkthroughService.save_state(user.id, data.get('state', data))except WalkthroughStateError as exc:@@ -46,7 +47,7 @@ def get_walkthrough_definitions():@walkthroughs_bp.route('/definitions', methods=['PUT'])@admin_requireddef update_walkthrough_definitions():- data = request.get_json(silent=True) or {}+ data = json_object(optional=True)try:definitions = WalkthroughDefinitionService.save_definitions(data.get('definitions', data),diff --git a/backend/app/api/workspaces.py b/backend/app/api/workspaces.pyindex 606a3fff..db720241 100644--- a/backend/app/api/workspaces.py+++ b/backend/app/api/workspaces.py@@ -8,6 +8,7 @@ from app.models.audit_log import AuditLogfrom app.middleware.rbac import (admin_required, get_current_user, require_workspace_access, require_workspace_role,)+from app.api._request import json_objectworkspaces_bp = Blueprint('workspaces', __name__)@@ -145,7 +146,7 @@ def add_member(workspace_id):if role not in ['owner', 'admin'] and not user.is_admin:return jsonify({'error': 'Insufficient permissions'}), 403- data = request.get_json() or {}+ data = json_object()user_id = data.get('user_id')if not user_id:return jsonify({'error': 'user_id required'}), 400@@ -167,7 +168,7 @@ def update_member_role(member_id):denied = require_workspace_role(member.workspace_id, user, ['owner', 'admin'])if denied:return denied- data = request.get_json() or {}+ data = json_object()role = data.get('role')if not role:return jsonify({'error': 'role required'}), 400@@ -216,7 +217,7 @@ def create_api_key(workspace_id):denied = require_workspace_role(workspace_id, user, ['owner', 'admin'])if denied:return denied- data = request.get_json() or {}+ data = json_object()name = data.get('name')if not name:return jsonify({'error': 'name required'}), 400diff --git a/backend/tests/test_json_object_body.py b/backend/tests/test_json_object_body.pyindex 90db1a42..0236245d 100644--- a/backend/tests/test_json_object_body.py+++ b/backend/tests/test_json_object_body.py@@ -46,3 +46,19 @@ def test_an_object_body_still_reaches_the_route(client, admin_headers):resp = client.post('/api/v1/cron/jobs/job_x/toggle', data=json.dumps({'enabled': False}),headers={**admin_headers, 'Content-Type': 'application/json'})assert resp.status_code != 400 or resp.get_json().get('code') != 'validation.body_not_object'+++def test_optional_body_may_be_absent(client, admin_headers):+ """Action routes read optional settings: no body (or no JSON content type)+ is an empty dict, exactly as `get_json(silent=True) or {}` gave."""+ resp = client.delete('/api/v1/setup-health/snooze?key=setup.canonical_domain',+ headers=admin_headers)+ assert resp.status_code != 415+ assert (resp.get_json() or {}).get('code') != 'validation.body_not_object'+++def test_optional_body_must_still_be_an_object(client, admin_headers):+ resp = client.delete('/api/v1/setup-health/snooze', data='[]',+ headers={**admin_headers, 'Content-Type': 'application/json'})+ assert resp.status_code == 400+ assert resp.get_json()['code'] == 'validation.body_not_object'diff --git a/backend/tests/test_no_plan_references.py b/backend/tests/test_no_plan_references.pyindex 5c0e2ecf..df4ba244 100644--- a/backend/tests/test_no_plan_references.py+++ b/backend/tests/test_no_plan_references.py@@ -12,13 +12,18 @@ from pathlib import PathREPO = Path(__file__).resolve().parents[2]ROOTS = ['backend/app', 'frontend/src', 'builtin-extensions']PLAN_REF = re.compile(r'\bplan[- ]?\d{2}\b', re.IGNORECASE)+# The same citation wrapped across lines: "(plan" then "# 86 ...".+SPLIT_REF = re.compile(r'\(plan\s*\n\s*(?:#|//|\*)?\s*\d{2}\b', re.IGNORECASE)+# A bare section sign cites a plan section; one next to a real document+# name (``docs/REDESIGN_MAP.md §3``) is fine.+SECTION_REF = re.compile(r'^(?!.*(?:\.md\b|REDESIGN_MAP)).*§', re.MULTILINE)# A vendored, signed registry index: its text is not ours to edit.EXCLUDED = {'backend/app/data/registry_index.json'}# Files with references still to remove, at their current count. The count# may only go down; delete an entry once its file is clean.PENDING = {- 'backend/app/services/deployment_job_service.py': 4,+ 'backend/app/services/deployment_job_service.py': 5,}@@ -35,7 +40,8 @@ def _counts():text = (REPO / rel).read_text(encoding='utf-8')except (UnicodeDecodeError, FileNotFoundError):continue- hits = len(PLAN_REF.findall(text))+ hits = (len(PLAN_REF.findall(text)) + len(SPLIT_REF.findall(text))+ + len(SECTION_REF.findall(text)))if hits:found[rel] = hitsreturn found