APT multi-arch package parsing creates empty package names
- Dominant language
- Go
- Stars
- 17
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
## Summary
APT search results occasionally show entries with empty package names (e.g., `: [version][] (installed)`) when multi-architecture packages are installed.
## Root Cause Analysis
The issue occurs when dpkg returns multiple architectures for the same package (e.g., `libcurl4:amd64` and `libcurl4:i386`), but our search parsing only finds one entry.
### Technical Details
1. **APT search** finds: `libcurl4/jammy-updates,jammy-security,now 7.81.0-1ubuntu1.20 amd64 [installed]`
2. **Parsed as**: `{Name: "libcurl4", Arch: "amd64"}`
3. **dpkg-query returns TWO packages**: `libcurl4:amd64` AND `libcurl4:i386`
4. **First processing**: Finds `libcurl4` in map, processes correctly, deletes from map
5. **Second processing**: Can't find `libcurl4` in map (already deleted), creates empty PackageInfo
### Current Impact
- **Frequency**: <0.1% of packages affected
- **Severity**: Cosmetic only - no functional impact
- **Example Output**: `: [7.81.0-1ubuntu1.20][] (installed)`
## Proposed Solution
Implement proper multi-arch support by using `name:arch` as the key throughout the parsing pipeline:
### Changes Required
1. **ParseFindOutput**: Use `name:arch` as dictionary key instead of just `name`
2. **ParseDpkgQueryOutput**: Parse architecture from dpkg output and use matching key
3. **Display**: Show multi-arch packages as `package:arch` (e.g., `libcurl4:amd64`)
### Benefits
- ✅ Eliminates cosmetic parsing bug
- ✅ Provides accurate multi-arch representation
- ✅ Matches APT's actual behavior
- ✅ Useful for debugging multi-arch dependency issues
## Implementation Notes
- **Scope**: APT-specific (other package managers already handle this correctly)
- **Breaking Changes**: None - just improved accuracy
- **Files**: `manager/apt/utils.go`, `manager/apt/utils_test.go`
- **Complexity**: Low - ~20 lines of changes
## Test Cases
```bash
# Before fix
apt: libcurl4 [version][version] (installed)
: [version][] (installed) # ← Bug
# After fix
apt: libcurl4:amd64 [version][version] (installed)
apt: libcurl4:i386 [version][version] (installed)
```
## Priority
**Low** - This is a cosmetic issue that doesn't affect core functionality. The system works correctly for 99.9%+ of packages.
## Labels
- `enhancement`
- `apt`
- `parsing`
- `multi-arch`
Contributor guide
Assessment
This issue has not been assessed yet.