Skip to content
Back to skills

1889 Public Workspace Storage Calculation Fix 20807ba7

ASecurity

**Fixed/Implemented in version: 0.230.082**

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 11, 2026
testingpythonazuretestingdebuggingbackend

Works with

  • cli

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 1889-public_workspace_storage_calculation_fix_20807ba7 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1889 Public Workspace Storage Calculation Fix 20807ba7?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1889 Public Workspace Storage Calculation Fix 20807ba7
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1889-public-workspace-storage-calculation-fix-2080/badge)](https://www.skillsdirectory.com/skills/tools-only-1889-public-workspace-storage-calculation-fix-2080)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Public Workspace Storage Calculation Fix

**Fixed/Implemented in version: 0.230.082**

## Issue Description

Public workspaces were showing 0 bytes for storage sizes despite having documents, while group workspaces correctly calculated storage sizes from Azure Storage blobs.

## Root Cause Analysis

After fixing the field name issue (`public_workspace_id` vs `workspace_id`) in version 0.230.081, document counts were working correctly but storage calculations had several issues:

### Problems Identified:

1. **Incorrect folder prefix**: Public workspaces used `public/{workspace_id}/` but actual Azure Storage structure uses `{workspace_id}/`
2. **Inadequate fallback logic**: Public workspaces had basic fallback, but groups had sophisticated file-type based estimation
3. **Inconsistent error handling**: Public workspaces lacked the robust error handling that groups had
4. **Missing debug logging**: Insufficient debugging information for storage calculation issues

## Technical Solution

### Files Modified:
- `route_backend_control_center.py`: Updated public workspace storage calculation logic

### Changes Implemented:

1. **Fixed Folder Prefix**
   ```python
   # Before (incorrect)
   workspace_folder_prefix = f"public/{workspace_id}/"
   
   # After (matches actual storage structure)
   workspace_folder_prefix = f"{workspace_id}/"
   ```

2. **Enhanced Fallback Logic**
   ```python
   # Before: Simple sum query
   SELECT VALUE SUM(c.storage_account_size) FROM c 
   
   # After: File-type based estimation (matching groups)
   SELECT c.file_name, c.number_of_pages FROM c
   # Then estimate based on file type:
   # - PDF: ~500KB per page
   # - Word: ~300KB per page  
   # - PowerPoint: ~800KB per page
   # - Other: ~400KB per page
   ```

3. **Improved Error Handling**
   ```python
   # Before: Basic error logging
   debug_print(f"Error calculating storage...")
   
   # After: Robust error handling with fallback
   except Exception as storage_e:
       debug_print(f"❌ Storage calculation failed...")
       enhanced['activity']['document_metrics']['storage_account_size'] = 0
       enhanced['storage_size'] = 0
   ```

4. **Enhanced Debug Logging**
   - Added blob enumeration logging
   - Fallback estimation progress logging
   - Consistent debug markers matching group patterns

## Impact Assessment

### Before Fix:
- ❌ Public workspace storage always showed 0 B
- ❌ No fallback when Azure Storage client unavailable  
- ❌ Poor error handling caused calculation failures
- ❌ Minimal debug information for troubleshooting

### After Fix:
- ✅ Public workspaces calculate actual storage sizes from Azure Storage
- ✅ Intelligent fallback estimation when storage client unavailable
- ✅ Robust error handling prevents crashes
- ✅ Comprehensive debug logging for troubleshooting

## Technical Details

### Storage Container Structure:
```
public-documents container:
├── {workspace-id-1}/
│   ├── document1.pdf
│   └── document2.docx
├── {workspace-id-2}/
│   └── document3.pptx
└── {workspace-id-3}/
    ├── document4.txt
    └── document5.pdf
```

### Calculation Logic:
1. **Primary**: Enumerate blobs in `{workspace_id}/` folder, sum actual blob sizes
2. **Fallback**: Query document metadata, estimate sizes based on file type and page count
3. **Error**: Set storage size to 0 to prevent display issues

### File Size Estimations:
- **PDF files**: 500KB × number_of_pages
- **Word documents**: 300KB × number_of_pages
- **PowerPoint**: 800KB × number_of_pages
- **Other files**: 400KB × number_of_pages

## Testing and Validation

### Test Coverage:
- Storage client retrieval and blob enumeration
- Folder prefix correction validation
- Fallback estimation logic verification
- Error handling robustness testing
- Container usage consistency checking

### Validation Results:
- ✅ Folder prefix matches actual Azure Storage structure
- ✅ Fallback logic identical to proven group implementation
- ✅ Error handling prevents crashes and provides graceful degradation
- ✅ Debug logging enables effective troubleshooting

## Expected Behavior Changes

### Control Center Display:
Before:
```
HR          | Total Docs: 2 | AI Search: 880 KB | Storage: 0 B
IT          | Total Docs: 1 | AI Search: 160 KB | Storage: 0 B  
Service Desk| Total Docs: 4 | AI Search: 1.41 MB| Storage: 0 B
```

After:
```
HR          | Total Docs: 2 | AI Search: 880 KB | Storage: 1.2 MB
IT          | Total Docs: 1 | AI Search: 160 KB | Storage: 450 KB
Service Desk| Total Docs: 4 | AI Search: 1.41 MB| Storage: 2.8 MB
```

### Debug Output:
Enhanced logging provides clear insight into storage calculation:
```
💾 [PUBLIC WORKSPACE STORAGE DEBUG] Looking for blobs with prefix: dfbd222c-1aea-44c3-b1ac-6d9b7742682c/
💾 [PUBLIC WORKSPACE STORAGE DEBUG] Found 4 blobs, total size: 2847362 bytes
💾 [PUBLIC WORKSPACE STORAGE DEBUG] Fallback estimation complete: 2400000 bytes
```

## Related Issues

This fix completes the public workspace metrics consistency work started in version 0.230.080-081:
- 0.230.080: Implemented caching consistency
- 0.230.081: Fixed field name consistency (`public_workspace_id`)
- 0.230.082: Fixed storage calculation consistency

Public workspaces now have complete feature parity with group workspaces for document metrics calculation and caching.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.