Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

This PR fixes two issues with the Admin UI:

  1. Approximated DNS Widget 404 Error - Fixed the DNS widget failing to load authentication token
  2. Stuck Inventory Syncs - Added UI button to reset stuck GAM inventory syncs

Changes

Fix #1: Approximated DNS Widget 404

Problem: The DNS widget was making fetch requests without the Flask script_name prefix, causing 404 errors in production where the Admin UI is accessed via /admin prefix.

Solution: Updated templates/tenant_settings.html to retrieve and use the script_name from the settings-config data attribute when constructing the token endpoint URL, consistent with all other AJAX calls.

Impact: DNS widget now loads correctly on all settings pages in both local and production environments.

Fix #2: Stuck Sync Reset UI

Problem: When GAM inventory syncs hang or get stuck (e.g., "Writing Placements to DB"), users had no way to recover without manual database intervention.

Solution:

  • Added "Reset Stuck Sync" button in the Inventory section that appears when a sync is in progress
  • Button calls the existing /gam/reset-stuck-sync endpoint to mark hung syncs as failed
  • Includes confirmation dialog to prevent accidental resets
  • Allows users to start a new sync after resetting

Impact: Users can now recover from stuck syncs without needing database access or support intervention.

Testing

  • ✅ All unit tests pass (822 passed, 24 skipped)
  • ✅ All integration tests pass (174 passed, 75 skipped)
  • ✅ Pre-commit hooks pass

Files Changed

  • templates/tenant_settings.html - Added script_name to DNS widget fetch + reset button UI
  • static/js/tenant_settings.js - Added resetStuckSync() function

- Add 'Reset Stuck Sync' button that appears when a sync is in progress
- Calls existing /gam/reset-stuck-sync endpoint to mark stuck syncs as failed
- Allows users to recover from hung syncs without manual database intervention
- Button has confirmation dialog to prevent accidental resets
- Change batch operation logging from DEBUG to INFO level
- Add step-by-step logging for each batch write operation
- Log timing at each stage: loading existing IDs, processing items, flushing batches
- Add batch counter to show progress through large inventories
- Include item counts (new vs updates) in each batch log

This will help diagnose where syncs are getting stuck (e.g., loading existing IDs,
bulk insert, bulk update, or commit operations).
@bokelley bokelley merged commit fc4191e into main Oct 22, 2025
8 checks passed
EmmaLouise2018 pushed a commit that referenced this pull request Oct 24, 2025
* Fix Approximated DNS widget 404 error by adding script_name prefix to token endpoint URL

* Add UI button to reset stuck inventory syncs

- Add 'Reset Stuck Sync' button that appears when a sync is in progress
- Calls existing /gam/reset-stuck-sync endpoint to mark stuck syncs as failed
- Allows users to recover from hung syncs without manual database intervention
- Button has confirmation dialog to prevent accidental resets

* Add detailed logging to GAM inventory sync for debugging stuck syncs

- Change batch operation logging from DEBUG to INFO level
- Add step-by-step logging for each batch write operation
- Log timing at each stage: loading existing IDs, processing items, flushing batches
- Add batch counter to show progress through large inventories
- Include item counts (new vs updates) in each batch log

This will help diagnose where syncs are getting stuck (e.g., loading existing IDs,
bulk insert, bulk update, or commit operations).
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…ntextprotocol#537)

* Fix Approximated DNS widget 404 error by adding script_name prefix to token endpoint URL

* Add UI button to reset stuck inventory syncs

- Add 'Reset Stuck Sync' button that appears when a sync is in progress
- Calls existing /gam/reset-stuck-sync endpoint to mark stuck syncs as failed
- Allows users to recover from hung syncs without manual database intervention
- Button has confirmation dialog to prevent accidental resets

* Add detailed logging to GAM inventory sync for debugging stuck syncs

- Change batch operation logging from DEBUG to INFO level
- Add step-by-step logging for each batch write operation
- Log timing at each stage: loading existing IDs, processing items, flushing batches
- Add batch counter to show progress through large inventories
- Include item counts (new vs updates) in each batch log

This will help diagnose where syncs are getting stuck (e.g., loading existing IDs,
bulk insert, bulk update, or commit operations).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants