From be3a367e184db0536cdee9de0d2ba4eae02f8d3e Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Wed, 7 Jan 2026 09:12:57 +0100 Subject: [PATCH] fix: Update Hub API returns full response object (v0.6.0-r6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix hub update failing in wizard: - Change updateHub API expect from {success: false} to {} - Returns full response object {success: true, message: "..."} - Wizard can now properly check result.success - Enables getCollections() call after successful update Issue: Hub update showed "Hub update failed" despite success Cause: RPC expect field extracted only boolean value instead of full object Solution: Remove expect field to return complete response Frontend Changes: - htdocs/luci-static/resources/crowdsec-dashboard/api.js - callUpdateHub: Change expect: {success: false} to expect: {} - htdocs/luci-static/resources/view/crowdsec-dashboard/wizard.js - Add comprehensive error logging and catch handler - Better error messages with error.message details Backend Returns: {"success": true, "message": "Hub index updated successfully"} Version: 0.6.0-6 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .../luci-app-crowdsec-dashboard/Makefile | 2 +- .../resources/crowdsec-dashboard/api.js | 2 +- .../view/crowdsec-dashboard/wizard.js | 22 +++++++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/package/secubox/luci-app-crowdsec-dashboard/Makefile b/package/secubox/luci-app-crowdsec-dashboard/Makefile index 77818134..3e2188d0 100644 --- a/package/secubox/luci-app-crowdsec-dashboard/Makefile +++ b/package/secubox/luci-app-crowdsec-dashboard/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-crowdsec-dashboard PKG_VERSION:=0.6.0 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_ARCH:=all PKG_LICENSE:=Apache-2.0 diff --git a/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/crowdsec-dashboard/api.js b/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/crowdsec-dashboard/api.js index f0207a9a..0e75c563 100644 --- a/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/crowdsec-dashboard/api.js +++ b/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/crowdsec-dashboard/api.js @@ -128,7 +128,7 @@ var callRemoveCollection = rpc.declare({ var callUpdateHub = rpc.declare({ object: 'luci.crowdsec-dashboard', method: 'update_hub', - expect: { success: false } + expect: { } }); var callRegisterBouncer = rpc.declare({ diff --git a/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/wizard.js b/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/wizard.js index 3631fb62..164fefe8 100644 --- a/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/wizard.js +++ b/package/secubox/luci-app-crowdsec-dashboard/htdocs/luci-static/resources/view/crowdsec-dashboard/wizard.js @@ -137,9 +137,12 @@ return view.extend({ }, renderStep1: function(data) { + console.log('[Wizard] renderStep1 data:', data); var status = data ? data.status : {}; + console.log('[Wizard] status:', status); var crowdsecRunning = status && status.crowdsec === 'running'; var lapiAvailable = status && status.lapi_status === 'available'; + console.log('[Wizard] crowdsecRunning:', crowdsecRunning, 'lapiAvailable:', lapiAvailable); return E('div', { 'class': 'wizard-step' }, [ E('h2', {}, _('Welcome to CrowdSec Setup')), @@ -185,8 +188,13 @@ return view.extend({ }, _('Cancel')), E('button', { 'class': 'cbi-button cbi-button-positive', - 'disabled': !crowdsecRunning || !lapiAvailable, - 'click': L.bind(this.goToStep, this, 2) + 'disabled': (!crowdsecRunning || !lapiAvailable) ? true : null, + 'click': L.bind(function(ev) { + console.log('[Wizard] Next button clicked!'); + ev.preventDefault(); + ev.stopPropagation(); + this.goToStep(2); + }, this) }, _('Next →')) ]) ]); @@ -537,10 +545,12 @@ return view.extend({ }, handleUpdateHub: function() { + console.log('[Wizard] handleUpdateHub called'); this.wizardData.hubUpdating = true; this.refreshView(); return API.updateHub().then(L.bind(function(result) { + console.log('[Wizard] updateHub result:', result); this.wizardData.hubUpdating = false; this.wizardData.hubUpdated = result.success; @@ -549,12 +559,20 @@ return view.extend({ return API.getCollections(); } else { ui.addNotification(null, E('p', result.error || _('Hub update failed')), 'error'); + return null; } }, this)).then(L.bind(function(collections) { + console.log('[Wizard] getCollections result:', collections); if (collections) { this.wizardData.collections = collections; } this.refreshView(); + }, this)).catch(L.bind(function(error) { + console.error('[Wizard] Hub update error:', error); + this.wizardData.hubUpdating = false; + this.wizardData.hubUpdated = false; + ui.addNotification(null, E('p', _('Hub update failed: ') + error.message), 'error'); + this.refreshView(); }, this)); },