# Upload Test Results - Map ID 16950

**Test Date:** 2025-12-09
**Test Type:** First 10 records per shapefile layer
**Map ID:** 16950

## Summary

| Layer | Records Attempted | Records Uploaded | Status |
|-------|-------------------|------------------|--------|
| poles.shp | 10 | 10 | ✅ SUCCESS |
| segments.shp | 10 | 10 | ✅ SUCCESS |
| sites.shp | 10 | 10 | ✅ SUCCESS |
| access_points.shp | 10 | 0 | ❌ FAILED |
| network_elements.shp | 10 | 0 | ❌ FAILED |
| splicing.shp | 10 | 0 | ❌ FAILED |
| cabinet_boundaries.shp | 3 | 0 | ❌ FAILED |
| cables.shp | 3 | 0 | ❌ FAILED |
| parcels.shp | 3 | 0 | ❌ FAILED |
| permits.shp | 10 | 0 | ❌ FAILED |

**Overall:** 30 out of 59 records uploaded successfully (51%)

## Successful Uploads

### ✅ Poles (10/10)
- All records uploaded successfully
- Field mapping working correctly
- No errors

### ✅ Segments (10/10)
- All records uploaded successfully
- TypeId mapping working correctly
- No errors

### ✅ Sites (10/10)
- All records uploaded successfully
- Address fields mapping correctly
- State lookup working
- No errors

## Failed Uploads

### ❌ Access Points (0/10)

**Error:** API returns 500 error
```
PHP Warning: Undefined array key "isLocked"
```

**Root Cause:** The API expects `locked` field, but the uploader is sending `isLocked`

**Fix Required:** Change field name in `_upload_access_points()` method
```python
# Current (wrong):
ap_data = {
    "isLocked": 0  # ❌ Wrong field name
}

# Should be:
ap_data = {
    "locked": 0  # ✅ Correct field name
}
```

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:407`

---

### ❌ Network Elements (0/10)

**Error:** Silent failure (returns 500 error but not logged in debug output)

**Root Cause:** API likely rejecting due to missing or incorrect field

**Status:** Code was recently updated with correct typeId mapping - may need testing with debug output enabled

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:452-511`

---

### ❌ Splicing (0/10)

**Error:** Silent failure (returns 500 error but not logged in debug output)

**Root Cause:** API likely rejecting due to missing or incorrect field

**Status:** Code was recently updated with correct typeId mapping - may need testing with debug output enabled

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:537-598`

---

### ❌ Cabinet Boundaries (0/3)

**Error:** API returns 500 error
```
Database Exception: Field 'metric' doesn't have a default value
```

**Root Cause:** The `mapobject` table requires a `metric` field that's not being provided

**Fix Required:** Add `metric` field to info object data
```python
info_data = {
    "mapProjectId": int(map_id),
    "name": str(row.get('Name', f'Cabinet-Boundary-{idx}')),
    "mapinfoobjecttypeId": 3,
    "data": data,
    "color": "#ffffff",
    "alpha": "0.40",
    "metric": 0  # ✅ Add this required field
}
```

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:549-563`

---

### ❌ Cables (0/3)

**Error:** API returns 500 error
```
Database Exception: Field 'metric' doesn't have a default value
```

**Root Cause:** Same as cabinet_boundaries - missing `metric` field

**Fix Required:** Add `metric` field to info object data
```python
info_data = {
    "mapProjectId": int(map_id),
    "name": str(row.get('Name', f'Cable-{idx}')),
    "mapinfoobjecttypeId": 2,
    "data": data,
    "color": "#ffffff",
    "alpha": "1.00",
    "metric": 0  # ✅ Add this required field
}
```

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:591-598`

---

### ❌ Parcels (0/3)

**Error:** API returns 500 error
```
Database Exception: Field 'metric' doesn't have a default value
```

**Root Cause:** Same as cabinet_boundaries - missing `metric` field

**Fix Required:** Add `metric` field to info object data
```python
info_data = {
    "mapProjectId": int(map_id),
    "name": str(row.get('Name', f'Parcel-{idx}')),
    "mapinfoobjecttypeId": 3,
    "data": data,
    "color": "#ffffff",
    "alpha": "0.40",
    "objectgroup": str(row['Group 1']),
    "objectgroup2": str(row['Group 2']),
    "metric": 0  # ✅ Add this required field
}
```

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:634-641`

---

### ❌ Permits (0/10)

**Error:** API returns 422 validation error
```
Permit Status cannot be blank.
Permit Entity Type cannot be blank.
Permit ULR Type cannot be blank.
```

**Root Cause:** Missing required fields in permit data

**Fix Required:** Add required fields with default values
```python
permit_data = {
    "mapProjectId": int(map_id),
    "name": str(name),
    "poly": poly,
    "mappermitstatusId": 1,        # ✅ Add: Default to status 1
    "mappermitentitytypeId": 1,    # ✅ Add: Default to entity type 1
    "mappermitulrtypeId": 1        # ✅ Add: Default to ULR type 1
}
```

**Note:** Need to research the correct default values for these IDs from the API references.

**File:** `/home/ahall/Sandbox/dragnddrop/backend/verofy_uploader.py:699-703`

## Action Items

1. **CRITICAL - Fix Access Points**
   - Change `isLocked` to `locked` field name
   - Should result in immediate success

2. **HIGH - Fix Info Objects (Cabinet Boundaries, Cables, Parcels)**
   - Add `metric: 0` field to all info object creations
   - Should result in immediate success

3. **HIGH - Fix Permits**
   - Research correct reference IDs for permit types
   - Add required fields with appropriate defaults

4. **MEDIUM - Debug Network Elements & Splicing**
   - Add debug output (like access_points and sites have)
   - Verify typeId mapping is working
   - Check for any other missing required fields

## Next Steps

1. Apply the fixes identified above
2. Re-run test with same data to map 16950
3. Verify all layers upload successfully
4. Document any additional issues found
