System Bug Fixer Skill
- Objective
To rapidly identify, isolate, and resolve system anomalies such as:
-
Service startup failures (Port conflicts, DB connection errors)
-
Persistent "Ghost" Data (Menu items that won't disappear)
-
Logic inconsistencies between Frontend and Backend
-
Caching issues (Redis, Browser, Vuex)
- Methodology
Phase 1: The Health Check (Stop & Clear)
Before debugging a weird issue, ensure the environment is clean.
-
Kill Zombie Processes: taskkill /F /IM java.exe
-
Clear Ports: Check if 8080/6379 are truly free.
-
Restart Middleware: Restart Redis/MySQL if data seems "stuck".
-
Flush Logs: Rename backend.log (e.g., backend.log.old ) to ensure you are reading fresh logs.
Phase 2: Deep Log Analysis
Do not trust the UI. Trust the Logs.
-
Enable Debug Logging:
-
Add log.info("DEBUG_TRACE: Variable={}", var) in critical logical paths.
-
If utilizing MyBatis, inspect the ==> Preparing: SQL output.
-
Result Verification:
-
Does <== Total: 0 match your expectation?
-
Did the code actually reach your log.info ? If not, check try-catch blocks swallowing exceptions.
Phase 3: Data Integrity Verification
Code is often correct, but Data is wrong.
-
Direct DB Query: Use MySQL CLI/Workbench to query the raw data.
-
Example: SELECT * FROM sys_menu WHERE menu_name LIKE '%Cart%';
-
Compare menu_id in DB vs Code Hardcoding.
-
Cache vs Source:
-
Redis: FLUSHALL (in Dev) to rule out stale permissions.
-
User Permissions: Logout and Re-login to refresh Subject principal.
Phase 4: The "Nuclear" Option (Hardcoding & Isolation)
If logic seems inexplicably skipped:
-
Isolate: Create a localized test case (e.g., a specific if block).
-
Hardcode: Temporarily hardcode IDs to confirm control.
-
Example: if (id == 2021) remove();
-
Broaden Scope: Use toLowerCase() and .contains() instead of equals() .
- Common Fix Patterns (RuoYi Specific)
Menu/Permission Persistence
-
Symptom: Menu visible after Role revocation.
-
Fix: Check SysMenuServiceImpl.selectMenuTreeByUserId . Ensure getChildPerms isn't caching an old tree. Force backend restart.
Port In Use (8080)
-
Symptom: "Web server failed to start".
-
Fix: netstat -ano | findstr :8080 taskkill /PID <PID> /F
Frontend Not Updating
-
Symptom: Code changed, UI stuck.
-
Fix: npm run build:prod might be needed if not running dev . Disable Browser Cache (DevTools -> Network -> Disable Cache).
- Verification
After applying a fix:
-
Clean Start: Restart backend.
-
Clean Login: Logout -> Clear Browser Cache -> Login.
-
Log Confirmation: Verify the specific log entry for the fix appears.